Documents Directory Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the <Application_Home>/Documents directory and will be automatically backed up by iCloud. NSString *FilePath = [NSHomeDirectory() stringByAppendingPathComponent:@”Documents/users.xml”]; Caches Directory Data that can be downloaded again or regenerated should be stored in the […]
All posts by
TCP Client
This guide is based on the excellent Ray Wenderlick guide Adding A TCP Client To A ViewController Class In your #ViewController.h #import @interface MyViewController : UIViewController <NSStreamDelegate> //-ADD THIS { NSInputStream *InputStream; NSOutputStream *OutputStream; NSMutableData *OutputData; } – (void)TcpClientInitialise; @end In your #ViewController.m //************************************** //************************************** //********** VIEW WILL APPEAR ********** //************************************** //************************************** //View about to […]
UDP Server
This is based on using the AsyncUdpSocket library. If you don’t use git you’ll have to download a git client to get the library files. Add Framework To Your Project Select the project at the top of the left navigator panel, select the target and then select the Build Phases tab. In the Link Binary with […]
NSData General
Convert NSData To String NSString *MyString = [[NSString alloc] initWithData:MyData encoding:NSUTF8StringEncoding]; [MyString release]; Convert String To NSData NSData *data = [myString dataUsingEncoding:NSUTF8StringEncoding]; Length if (data.length > 0) Accessing Individual Bytes Converting the entire array UInt8 *bytes = (UInt8 *)data.bytes; if (data.length >= 4) NSLog(@”Byte0: %d, Byte1: %d, Byte2: %d, Byte3: %d”, bytes[0], bytes[1], bytes[2], bytes[3]); […]
Const Static Arrays
Create your array of values, in your .m file or before the @interface in your .h file, like this: static const UInt8 encryptionKey[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09}; Use it like this = encryptionKey[1]; while (offset >= (sizeof(encryptionKey) / sizeof(UInt8))) offset -= (sizeof(encryptionKey) / sizeof(UInt8));
Using URL’s
Basic URL NSURL *url = [NSURL URLWithString:@”http://www.mydomain.com/some_folder/movie.mov”]; //or NSString *urlAddress = @”http://www.google.com”; NSURL *url = [NSURL URLWithString:urlAddress]; Simple Downloading data from a URL Synchronous methods which block until they have the result: NSData *downloadData = [NSData dataWithContentsOfURL:url]; Same synchronous method but with Options and Error //—– DOWNLOAD FILE —– NSError *error = nil; NSURL *url […]
Playing A Movie
The MPMoviePlayerController plays video content. You initialize it with the URL of the media play which can be either a path to a local movie file or the URL of network based media. The movie player view is added as a subview of a view with the playback window run in full screen mode or […]
Crash Logs General
Ensuring your application has symbols for debugging any crash reports Set Generate Debug Symbols set to YES for Release builds.= (in Build Settings > 'Apple LLVM 5.1 – Code Generation') Getting Crash Logs Directly From A Users Computer After Syncing With iTunes Follw this aplus moments guide.
Programatically Controlling Views
Don't want to use UINavigationController or UITabBarController? Then you have a problem as Apple doesn't provide the means to control an apps views programatically very easily, for instance using code like this: [viewController.view addSubview:AnotherViewController.view]; This aritcal explains the problem very well. Solutions Ignore the porblem! This might be Ok if your app doesn't need to […]
Creating Provisioning Profile For An App
In the Developer Center select ‘iOS Provisioning Portal’ Select App ID’s Create New App ID Description: As required Bundle Seed ID: Generate new Bundle Identifier: com.mydomain.MyApName (and use this in Shared > MyApName-Info.plist > Bundle Identifier) Create it Now go to ‘Provisioning’. Select ‘Development’ to install your application on a test device and select ‘Distribution’ […]