Breaking News
Home / iOS / iOS Snippets

iOS Snippets

How to get Memory Stats in an iOS app?

Knowing the amount of memory in the device is very critical esp. if you are trying to figure out memory leak. We can use C API to find out the Free, Used and Total memory of the device. The following method shows how to print out the memory stats. This …

Read More »

How do you set a background image in UINavigationBar in iOS?

In order to set a background image for the navigation controller use the following code: // get handle to nav bar UINavigationBar *navBar = self.navigationController.navigationBar; // get imageUIImage *image = [UIImage imageNamed:@”backgroundImageToSet.png”]; // set the bg image[navBar setBackgroundImage:image]; in the viewWillAppear method. – (void)viewWillAppear:(BOOL)animated [pb_builder]

Read More »

How to remove all files of a particular type from a directory in iOS?

Lets say you want to remove(delete) all the files of a particular extension say PNG from the Documents folder of the app. We can use the following code snippet. NSString *fileExt = @"png"; // get the file manager NSFileManager *fmanager = [NSFileManager defaultManager]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); // …

Read More »
Advertisment ad adsense adlogger