Jul 31, 2014



Category: Games
Released: Jul 30, 2014
Version: 1.0
Size: 0.3 MB
Language: English

Link iTunes

Jul 17, 2014

[iOS] How To Read a File From Your Application Bundle

First you need to add your file to the Resources folder of your Xcode project. Then you can access the file like this (assuming the file is called MyFile.txt):

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyFile" ofType:@"txt"];
NSData *myData = [NSData dataWithContentsOfFile:filePath];
if (myData) {
    // do something useful

Here’s a complete example reading a help text file into a UIWebView.

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"HelpDoc" ofType:@"htm"];
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
if (htmlData) {
    [webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@"http://iphoneincubator.com"]];

If you want to read the file into a string, which you can then display in a UITextView, for example, then do this:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"important" ofType:@"txt"];
if (filePath) {
    NSString *myText = [NSString stringWithContentsOfFile:filePath];
    if (myText) {
        textView.text= myText;

[iOS] Getting current device language in iOS?

NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0]; 

NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
NSArray* arrayLanguages = [userDefaults objectForKey:@"AppleLanguages"];
NSString* currentLanguage = [arrayLanguages objectAtIndex:0]; 


NSString *language = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];

Jul 10, 2014

[iOS] how to clear notifications?

[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];

Jul 1, 2014

[iOS 8] iOS registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later

Its very simple try this (Xcode6 Beta only):

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    //-- Set Notification
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
            [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
            [[UIApplication sharedApplication] registerForRemoteNotifications];
            [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
             (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
     //--- your custom code
     return YES;