Pages

Wednesday, February 1, 2012

[Code Snippet] Read application bundle identificator from plist.

Hi mates!!

A lot of work, so as usually we have not time to update the blog as we want, but today's we've get 5 free minutes to post a new code snippet.

I know, because I just tried to do it, that most of you have tried to read application bundle Id from the plist asi usual, getting the path to the plist file, obtaining its values and getting the correct key.

There's a shorter way to accomplish that, just using NSBundle infoDictionary property that returns us the values stored in our Project-Info.plist.


        NSString* appID = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];

I hope this will be useful for everyone, but now I may continue developing. Turning back to my XCode!

Regards!

Thursday, January 12, 2012

New iphone apps

We have released to app store two new apps based on geolocated photography and oriented to hunting and fishing fans.

First of both was Hunting Log, in which you can store geolocated photos of your hunted pieces and share it with your friends via Twitter and Facebook.

Fisherman's Log has the same functionallity but oriented to fishing lovers.

You can find more info about these apps and our complete portfolio for iOS, Android and Windows Phone in our website: www.fiveflamesmobile.com

Aborting performSelectorInBackgroud:withEvent

First of all, happy 2012. Our best wishes to all of our readers in this new year.

Once again we have to apologize our readers for the lack of updates, but we have a lot of work, maybe there will be some changes in our work and we don't have so much time to update the blog.

Today's entry is not a code snippet as usual, is a little trick for when we are performing any task in background and we want to cancel it. For example, I want to accomplish it when a user taps back button during an array data loading performing in background.

The only way to abort a background task is to define a class boolean variable accesible for any method.

BOOL cancelBackgroundTask

set it to NO when you lauch the task

cancelBackgroundTask = NO;
[self performSelectorInBackground:@selector(bgTask) withObject:nil];

If the user makes any action that should abort the background task, just change the boolean value

cancelBackgroundTask = NO;

And at last, in background task you have to check this variable periodically with an NSTimer or a worse approach but maybe usefull is to check it before perform any action.

if (!cancelBackgroundTask)
    [self loadData];

if (!cancelBackgroundTaks)
    [self presentData];

In this easy way you could abort a background task. This derived of the lack of a function to abort or cancel directly a thread.

I hope this help, enjoy it!