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!

Thursday, December 15, 2011

[Code Snippet] Rounded corners for UIView

We are very sorry about the lack of updates for the block, but now we are overloaded of projects and have no much time to write new posts :(

Here is a little and useful code snippet to round the corners of any UIView (UIWebView, UIImageView, etc...)

You have just to link your binaries with QuartzCore library and import it in the .h file.

#import <QuartzCore/QuartzCore.h>

And in .m file, you have to use this code snippet to round the corners. In the examble I've did it with a UIImageView

[imgView.layer setBorderColor:[UIColor blackColor].CGColor];
[imgView.layer setBorderWidth:1.0f];
                    
[imgView.layer setCornerRadius:10];
[imgView setClipsToBounds:YES];

With this four lines of code, you'll give your app a better look and feel.

Enjoy it!!

P.S. Don't forget to visit our web to see a complete catalogue of our apps.

Monday, December 5, 2011

New web site

We are proud to present you our new official web site: http://www.fiveflamesmobile.com in which you can see all of our developments for iOS, Android and Windows Phone.

This was the cause of the lack of updates of the blog, but don't worry because this blog will continue publishing articles for iOS and Windows Phone developers in blogspot.

We hope that you like our new web site and continue visiting this blog.

Regards!

Five Flames Mobile Team

Wednesday, November 16, 2011

[Code Snippet] Accesing to SSL server trust web services

This code snippet completes the two previous post that says how to connect to a REST service and consume it synchronous and asynchronously.

When we have to access a HTTPS web service first thing that we should think is how to store the trusted root certificate in our iPhone or iPad. Our device has installed some of the most used certificates (you can check the list here) and for this snippet we asume that the server uses Verisign, GoDaddy or any other common SSL certificate, so we have yet installed it.

To accomplish this task you should implement the next functions of NSURLConnection delegate:


- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection
{
    return TRUE;}
-(void)connection:(NSURLConnection *)connection didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
    NSLog(@"Challenge cancelled");}
-(BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
{
   // Server Trust authentication method
    return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
  
    //Here we told the OS that validate the server certificate against our credential storage.
    [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];       
    NSLog(@"Reto superado");}

If we just want to bypass the authentication, instead of useCredential, we should use continueWithoutCredential method in didReceiveAuthenticationChallenge.

    //Bypass without credentials
    [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];

I hope this code snippet could be useful for you, enjoy it!

NOTE: This can be used only with NSURLConnection, just for asynchronous request.

Working in progress...

Hello everyone.

We're sorry for the lack of updates of the last weeks but J.A.Gallego was travelling round Spain with Windows Phone Roadshow and I was also very busy with a suite of nature oriented new iPhone (and maybe iPad optimized in the future) apps.

We're also creating a new web site, exclusively for our apps and games with the help of Virginia, our graphics designer, we'll keep this blog only for code snippets and geek stuff at blogspot for those who has it in their bookmarks and create a separately web for apps and projects to give them more visibility.

At last we are in the way to port Vinos de Cigales and Car Charge to Windows Phone and Android OS, so it's possibly that in the next days two new guys will be added to Five Flames Mobile staff...

These are the causes of the lack of updates, Twitter has been updated frequently but the blog wasn't so we apologize and will try to recover our weekly updates.

Thanks to all of our followers!