04

Sep

iOS Twitter integration stopgap

I think it's fair to state that most-if not all-iOS developers are excited about iOS 5.0's OS level integration with Twitter. While we wait for iOS 5.0 to arrive and for users to upgrade, integrating Twitter into an iOS app can be done in one of two ways.

One: the purist way

The purist way is to use Twitter's strict OAuth 1.0 support to enable the user to login to twitter using a webkit webview from within your app. Doing this usually requires using a half-baked open-source library (if you can call it that) to manage the webView and strip

16

Jul

Easiest way to download remote files for iOS

I updated and open-sourced a utility for downloading web-hosted files for iOS today. Using it is extremely easy and doesn't require any notifications or delegates. Only sexy block syntax.

First, you'll need to import it in your implementation file:

 #import "RemoteDataManager.h" 

Then you can:

 NSString *location = @"http://tailsmagazines.files.wordpress.com/2009/04/kitten.jpg?w=320&h=480"; [[RemoteDataManager sharedManager] getDataAtLocation:location withCallback:^(BOOL waiting, NSData *data){ if(waiting){ // if the data is not cached [loadingIndicator startAnimating]; } // when the data is available else{ [loadingIndicator stopAnimating]; imageView.image = [UIImage imageWithData:data]; } }]; 

The key thing to acknowledge here is that the Callback block may get

17

Jun

Konstructor: Easy TableViews for iOS

Creating TableViews is one of the many very verbose tasks in iOS development. Every attribute of the table and the cells has to be customized by implementing a different protocol method.

Not anymore

Thanks to the magic of blocks, the overly terse task can become something declarative, readable and even fun!

Here's an example of what it can be with Konstructor:

 self.tableCellHeight = 100.0; /* Create an array of data. You'll likely do this completely differently */ NSDictionary *gloves = [NSDictionary dictionaryWithObjectsAndKeys:@"Gloves", @"name", @"for your hands", @"caption", nil]; NSDictionary *muffs = [NSDictionary dictionaryWithObjectsAndKeys:@"Muffs", @"name", @"for your ears", @"caption",

18

Jan

VoiceBook iPhone App

I ripped the facebook audio status functionality out of Murmur today and threw it into it's own application and named it "VoiceBook".

It's here. Download it from iTunes

06

Dec

Murmur iPhone Launching...

Any day now...

UPDATE: Here at last! Get it here.

11

Nov

Sartorialist iPhone Now Available!


It's finally here!

I recently created an application for the Sartorialist that ports his blog to the iPhone as a slideshow of his beautiful images. You can save them to your photo roll and then set them as wallpaper, or share them via facebook.

Check it out here: iTunes Link

10

Oct

NSOperation and NSURLConnection conflicts

The right way to use NSOperation, NSOperationQueue and NSURLConnection

I stumbled across a problem today when trying to make an asynchronous POST request to a server.

I created a request class by subclassing NSOperation and was calling it by adding it to an NSOperationQueue (more here) and within this class's (void)main method, I was creating an NSURLConnection like this:

 NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self] 

The problem I was experiencing was none of the NSURLConnection delegate callbacks were being fired.

After a little research I realized that when you create an NSURLConnection using the initWithRequest

26

Aug

NSXMLParser doesn't fire - (void)parserDidEndDocument:(NSXMLParser *)parser

Today I ran into an issue where an NSXMLParser would not fire the parserDidEndDocument delegate method. I was parsing XML stored locally and it turned out to be an issue with a trailing newline at the end of the document.

To fix it, I made sure there was no newline at the end of the final closing XML tag. This seems lame of NSXMLParser or is there a convention I am just not aware of?

Nevertheless, I hope this helps someone.

12

Feb

Hacking the MPMoviePlayer framework on the iPhone

Wouldn't it be great if you could change the frame of the media player? If you could take the full screen window and fit it in a custom CGRect and place it where-ever you want on the window?

Well, you can, but it's undocumented, so hack at your own risk, but here's how.

First thing you should know is you can't hack the window until you start playing the video. Once you issue the play command to the MediaPlayer framework, it adds a new window to the window stack. So - you have to find it:

 NSArray *windows

30

Jan

MPMoviePlayerController comprehensive method list including undocumented

For your iPhone Media Player hacking pleasure:

 "- (@) _localizedDescriptionForErrorCode:(i)arg0 ", "- (@) _volumeAudioCategory", "- (@) backgroundColor", "- (@) contentURL", "- (@) init", "- (@) initWithContentURL:(@)arg0 ", "- (@) movieView", "- (@) videoViewController", "- (c) hideLoadingIndicatorForLocalFiles", "- (c) isFullscreen", "- (d) currentTime", "- (I) _visiblePartsForMovieControlMode", "- (i) movieControlMode", "- (i) orientation", "- (i) scalingMode", "- (v) _audioRouteChanged:(@)arg0 ", "- (v) _bufferingStatusDidChangeNotification:(@)arg0 ", "- (v) _createPlayer", "- (v) _expireImplicitAudioRouteChangePlaybackRestart", "- (v) _itemDidChangeNotification:(@)arg0 ", "- (v) _itemFailedToPlay:(@)arg0 ", "- (v) _itemFailedToPlayMainThreadCallback:(@)arg0 ", "- (v) _mediaServerDied:(@)arg0 ", "- (v) _mediaServerDiedMainThreadCallback:(@)arg0 ", "- (v) _movieDidDecode:(@)arg0 ", "- (v) _movieDidDecodeMainThreadCallback:(@)arg0 ", "- (v)