How To Install Cocoapods Appliations > Utilities > Terminal sudo gem install cocoapods pod setup If it fails due to "Failed to build GEM native extension" ensure the xcode Command Line Tools are installed: In xcode close any open project, then Preferences > Downloads > Components and click the download down arrow icon next to […]
All posts by
Running In Background
Your app can request the system to let it run in the background. Once you have doen this you can check the UIApplication's property called "backgroundTimeRemaining". This is usually 11 minutes (but may change in the future). Apple Guide "App States and Multitasking" Lock Button Pressing the Sleep/Wake button causes the system to disable touch […]
Can we connect
Get A Small File Method This test will lock up if there is WiFi but no internet connection: if (![self.reachability isReachable]) This works much better as it tests the connection to an actual file on the server you want to connect to (assuming you can get a named file from it) and allows you to […]
Working With Strings
URL Encode A String NSString *UrlEncodedString = MyStringToEncode stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
Read JSON File
Read the JSON file Get the File //Get file on a background thread to stop GUI locking up dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@”http://mydomain.com/comefile.php”]]; //Could obviously be a .json file too [self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES]; }); File Received //**************************************** //**************************************** //********** JSON FILE RECEIVED ********** //**************************************** //**************************************** – (void)fetchedData:(NSData *)responseData { […]
Run a synchronous method in a background thread
Running a synchronous method in a background thread is a great way of avoiding GUI seeming unresponsive to the user. Getting a file example Get a file //Get file on a background thread to stop GUI locking up dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@”http://mydomain.com/comefile.php”]]; [self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES]; }); File Received //*********************************** […]
Constants
String Constants In your .h file extern NSString *const MyKey; Your declaration NSString * const MyKey = @"12345";
-Dev Center Basics
Keychain access stores the main certificates. The Xcode Organizer stored provisioning profiles which rely on the certificates in keychain access. If a provisioning profile has a message like "valid signign identity not found" then you don't have a valid certificate for it in Keychain Access. Remember that you must have the private key for certificates […]
-Dev Center Certificates
You Need The Private Key!!! You can't just download a certificate someone else created or that you created on another computer. If you don't have the private key the certificate was created imported into Keychain Access with it won't work! Helpfully, keychain access wont tell you this but when you click on the downloaded certificate Keychain […]
NSUserDefaults For Saving & Retrieving Data Using
Using NSUserDefaults is great when you want to save small amounts of application data such as log in, last settings, etc An Example Saving NSUserDefaults *NonVolatile = [NSUserDefaults standardUserDefaults]; [NonVolatile setObject:@”TextToSave” forKey:@”keyToLookupString”]; //Saving an NSString [NonVolatile setInteger:42 forKey:@”integerKey”]; //Saving an NSInteger [NonVolatile setBool:YES forKey:@”boolKey”]; //Saving a BOOL [NonVolatile setDouble:3.1415 forKey:@”doubleKey”]; //saving a Double [NonVolatile setFloat:1.2345678 forKey:@”floatKey”]; […]