Posts Tagged 'Programming'

CATiledLayer

Excellent introduction to CATiledLayer over at Cocoa Is My Girlfriend today:

Subduing CATiledLayer

… It seems like a magical sort of technology because so much of its implementation is a bit of a black box and this fact contributes to it being misunderstood. CATiledLayer simply provides a way to draw very large images without incurring a severe memory hit. This is important no matter where you’re deploying, but it especially matters on iOS devices as memory is precious and when the OS tells you to free up memory, you better be able to do so or your app will be brought down. This blog post is intended to demonstrate that CATiledLayer works as advertised…

Read and enjoy! With just one caveat; if you intend to use CATiledLayer in 3.x compatible projects, read QA1637 first, or CRASH HORRIBLY. Whichever.

Continue Reading →
0

Sensible TableView

So you want some more help with your table views than the open source tutorials we’ve mentioned here and there? Weeeelll, maybe you want to spend some money — $99, to be exact — and buy Sensible TableView. What do you get for that $99? Quite a bit, reputedly:

This easily is the best iOS TableView framework I’ve ever seen!

… Sensible TableView (STV) is the most comprehensive, fully featured and best designed Table View framework I’ve ever seen. It literally shortens a task that took 4-5 hours in the past to just a few minutes.

As an example, the table view [below] takes roughly five lines of code. That’s it!

stv.png

You don’t have to deal with UITableView’s many delegate methods nor do you have to reinvent the wheel time and again, as STV gracefully handles all of this for you in the background.

The way STV works is pretty unique, too.

It basically takes your Objective-C data transfer objects or – should you use it – your Core Data objects and leverages the Objective-C runtime to learn about their structure and properties. From that information it automagically creates a fully functional, basic Table View Model…

Yep, sounds pretty interesting. If you’ve done any work with it, let us know if you’re as enthralled with it as that fellow!

h/t: @iPhoneDevGuy!

Continue Reading →
0

Mac App Store vs. Download

Trying to deal with Mac App Store vs. direct downloads of your app? Here’s some good thoughts:

This App Is Your App

… This leads to a conundrum if you continue to sell software directly, or offer preview beta releases for direct download. How can you offer access to these releases for customers who purchased through the MAS and thus do not have the “Registration Code” that direct-purchase customers receive? Apple provides no means of determining the identities of, or contact information for, authorized MAS customers. But even though I don’t know who these customers are, I want to treat them as first-class customers in every regard.

For me, I decided that the compromise is to provide, for those MAS customers who want it, full access to the direct-download versions of my software. Today, any customer who buys a MAS edition of my applications will find that, after running that edition at least once, they are automatically authorized to run direct-download versions of the app from that time forward…

Not really what we’d call a good solution … but good solutions are pretty much impossible without some accommodation of this situation on Apple’s part. In the meantime, this is about as good advice as it gets.

UPDATE:

Here’s another excellent article, Mac App Store Guide:

Unfortunately, there’s not much information on how to create a product that can also be distributed through more traditional channels, such as your own product website. This guide will help you update your Xcode projects to make it as simple as possible to create products for both channels simultaneously…

Continue Reading →
0

Cocoa C++ Wrappers

So let’s say that you’re looking at developing an iPhone app that needs to share source with Another Platform, so C++ is the logical common ground; but you’d like to keep your iPhone side written the right way, of course. Here’s a helpful post about wrapping std::vector in an NSArray:

Mixing STL, NSArray and Bindings

I am currently writing a crossplatform library that needed to be quick, small and efficient. The library is a parser for a particular file format that I need to work with. The library needs to work on Mac, Windows, and with Java through JNI.

I thought about using Objective-C for the engine and then using GNU-Step or CocoTron but that has a huge overhead and writing the JNI would be a night mare. I didn’t want to write it in straight C, i wanted to use STL’s strings and collection classes and boost’s smart pointers. So C++ it was.

When writing the Objective-C wrapper and test app I wanted to use Cocoa’s bindings mechanism to quickly display the results. The solution was to wrap the classes, very thinly, using an NSArray wrapper around the vector.

In this article we will walk through writing a thin wrapper around a C++ object that parses lines of text out of stores those lines in a vector of strings. The sample project can be downloaded from here

Another interesting bit here:

Hoard: A Nice Abstraction on Cocoa Collections

… Hoard gives you a super simple way to instantiate collections of any sort, containing data of any type, and then “view” that data as one of several available collection types (including both Cocoa and STL collections). You can also instantiate a hoard from any of the included Cocoa or STL collections…

Any libraries, patterns, or snippets to add here that you’ve found useful in constructing C++/Objective-C core functionality engine bits, Dear Readers?

Continue Reading →
0

JSON Parsing

Looking for a JSON parser? Care about speed? Check out

Cocoa JSON parsing libraries, part 2

Compares:

and the takeaway?

… So if you’re looking for a fast JSON library for your iPhone app, choose JSONKit.

There you go then!

h/t: @shashivelur!

UPDATES:

March 2011: plist vs. JSON comparison here with some different contenders, same general conclusion.

December 2011: JSON Libraries for iOS Comparison … yep, new choices, same conclusion.

Continue Reading →
2

Blocks Party

Excellent article here at Cocoa Samurai on applications of blocks to make your coding easier, intelligibler, threadsafer, and generally awesomer:

Practical Design Patterns with Blocks and Grand Central Dispatch

following on from the likewise excellent introduction to blocks

A Guide to Blocks & Grand Central Dispatch (and the Cocoa API’s making use of them)

And while we’re talking about blocks and GCD, there’s a whole folder full of links here from introductions onwards through tips, tricks, and issues we were going to get around to listing someday, and someday might as well be now:

bbum’s Basic Blocks and Blocks Tips & Tricks

Mike Ash’s Intro to Grand Central Dispatch Part I and Part II and Part III

Fiery Robot!s Being a Blockhead and A Simple Job Queue With Grand Central Dispatch and A Watchdog Timer in GCD and Synchronization Using Grand Central Dispatch

Mike Clark’s Using Blocks in iOS 4: The Basics and Designing with Blocks

Ask Big Nerd Ranch: Blocks in Objective-C

Programming with C Blocks On Apple Devices

Seriously, a blocks + NSURLConnection + NSOperationQueue async HTTP request library

Enumerating Lines Concurrently using a Block (see snippet from comments)

Making NSArray more ruby-ish block-based category of conveniences

Fun with Glue for wrapping to suit target/action APIs and deallocation watchdoggery

Block Retain Cycles and how to avoid them

Cyclic Retention Pitfall in Objective-C Blocks

An NSNotification + Blocks Gotcha with The Solution

NSInvocation+blocks

Asset Libraries and Blocks in iOS 4 and Cloning UIImagePickerController using the Assets Library Framework

Combining Blocks, Properties and Animation in Objective-C

Core Animation using blocks

Blocks & View Transitions Snippet

and to finish up with a little light amusement, for some value of “light”:

Trampolining Blocks with Mutable Code

… Do not, under any circumstances, use this code…

but as with all stuff Mike Ash-ish, an illuminating read nevertheless!

UPDATES:

Block Based UIAlertView and UIActionSheet + Block based performSelector

iOS 4.3: imp_implementationWithBlock()

Delayed Blocks in Objective-C

A Tour of MABlockClosure

Programming with Blocks: an overview

Massive Collection Of Objective-C Blocks Extensions

BlocksKit — “The Objective-C block utilities you always wish you had.”

Excellent Video Presentation For Understanding GCD

A Y-Combinator for Objective-C

Generic Block Proxying

Creating retain cycles by misusing assertions

Recursive Blocks in Objective-C

Leak-Free Recursive Blocks

sleroux / KVO-Blocks: “Bringing KVO into the modern world”

zuccoi / REKit: “A collection of NSObject extensions that brings out Blocks latent ability”

Continue Reading →
1

MTStatusBarOverlay

This is kinda nifty: Feel like using the status bar for … well … status, like this,

Screen shot 2011-02-22 at 10.32.44 PM.png

or to bring down a detail view?

Screen shot 2011-02-22 at 10.33.32 PM.png

What you need then is MTStatusBarOverlay on github!

This class provides a custom iOS (iPhone + iPad) status bar overlay window known from Apps like Reeder, Google Mobile App or Evernote. It currently supports touch-handling, queuing of messages, delegation as well as three different animation modes:

  • MTStatusBarOverlayAnimationShrink: When the user touches the overlay the overlay shrinks and only covers the battery-icon on the right side
  • MTStatusBarOverlayAnimationFallDown: When the user touches the overlay a detail view falls down where additional information can be displayed. You can get a history of all your displayed messages for free by enabling historyTracking!
  • MTStatusBarOverlayAnimationNone: Nothing happens, when the user touches the overlay

Check out the rest of myell0w’s projects while you’re there for some more goodies!

h/t: ManiacDev!

Continue Reading →
0

UITableView Revisited

We’ve mentioned before various UITableView tips from Matt Gallagher, but here’s a collection of his current practices worth checking out:

UITableView construction, drawing and management (revisited)

In this post, I’ll show you the current classes I use to construct and manage UITableViews in a number of different projects. This code is an amalgamation and evolution of some ideas that I’ve presented in a few earlier posts including my posts on heterogenous cells in a table view and easy custom table view drawing. But this implementation also chooses to do some things differently in an effort to continuously simplify the task of creating customized tables and views in iOS…

Good tips on structure, creation, etc. you may find worth adopting; we particularly enjoy the pretty, pretty cell animations in place of calling -reloadData. It’s all about the pretty. Almost as much as the shiny!

Continue Reading →
2

Compound Literals

Never ceases to amaze how that Mike Ash fellow keeps teaching us new stuff about the basic C language. The latest is

Friday Q&A 2011-02-18: Compound Literals

This time we were sure there wouldn’t be anything new to us, we use compound literals for field initialization every time we create a struct pretty much … and wrong again!

Specifically, did you know that compound literals are mutable?? We did not know that compound literals are mutable

One really unintuitive thing about compound literals is that, unless you declare their type as const, they produce mutable values. The following is perfectly legal, albeit completely pointless, code:

   (int){ 0 } = 42;

Less uselessly, this fact means that you can take the address of compound literals, and it’s safe to pass them to code which will modify the pointed-to value…

A fairly trivial syntactic convenience in most cases, but there is one instance where it can make your code significantly more clear and robust, and that’s when writing functions with optional parameters; things taking NSError ** for example. Which you typically write with if (*error) every few lines … unless you forget to do so until it crashes … or you keep auxiliary errors, or something tedious, anyways. Taking this mutability into account, you’d write something like

    - (BOOL)doWithError: (NSError **)error
    {
        if(!error)
            error = &(NSError *){ nil };

        if(fail1)
        {
            *error = [NSError ...];
            return NO;
        }
        if(fail2)
        {
            *error = [NSError ...];
            return NO;
        }

        return YES;
    }

Well, that’s rather more straightforward and robust, isn’t it? Yes, we will definitely adopt that style from now on.

Lots of other good tips and discussion in the article and comments, so read all the way to the end!

Continue Reading →
1

XML Interchange: Fremont

So let’s say you’ve got XML parsing needs more complex than RSS reading, or even worse, you actually have to exchange data with some back end service in XML format. Lot of work ahead? Well, maybe not, check this out:

Fremont XML Library – “The best XML code is code that you don’t have to write.”

If you are developing software programs that integrate with external systems, be they client/server or web-service based applications, it is highly likely you’ll cross paths with XML as a data interchange format. As the number of XML messages that must be exchanged grows, the need to write XML parsing and generating code becomes very redundant. After encountering this XML coding requirement in app after app, we decided to eliminate this repetitive coding task. The result: Fremont XML Library.

Built for iOS, Fremont is an Objective C static library which provides serialization and deserialization capability between XML documents and Objective C object hierarchies. Development requires declarative definition of the mapping between XML document structure and Objective C class structure in XML format. Fremont uses this mapping, or model definition to do all of the work in translating between structures.

Eliminate the need to do XML coding, and save countless hours of development time!

Well, that sure sounds appealing, doesn’t it now? Source is on github, go wild!

h/t: @osxdevel!

Continue Reading →
1
Page 31 of 82 «...10202930313233...»