Tag: objective c

What is the main difference between framework and dynamic library

What is the main difference between frame work and dynamic library

How to create a confirmation Pop Up when pushing Back button in iOS?

I want to add a pop up when someone pushes the “Back” button of my iOS App, to ask the user if he really wants to come back. Then, depending on the user’s response, I would like to undo the action or proceed. I’ve tried to add the code in the viewWillDisappear function of my […]

Does converting NSString to NSData force a trailing byte?

This is in response to this incorrect answer: https://stackoverflow.com/a/7894952/192819 Does converting NSString like this: NSString *str = @”teststring”; NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding]; force a trailing \0 byte, which means -[NSJSONSerialization:JSONObjectWithData:] and others will fail unless you remove it.

Why doesn’t my NSMutableArray subclass work as expected?

I have subclassed NSMutableArray as follows: Base Class: @interface MyBaseMutableArray : NSMutableArray { // Database variables NSString * databaseName; NSString * databasePath; } @property (nonatomic, retain) NSString * databasePath; – (id)initWithContentsOfSQLiteDB:(NSString *)dbTable; -(void) checkAndCreateDatabase; -(void) readFromDatabase; @end Subclass: @interface IngredientsMutableArray : MyBaseMutableArray { } -(void) readFromDatabase; @end When I create an IngredientsMutableArray I do the […]

Releasing a delegating object in its delegate callback method

I’m trying to figure out what the recommended practice is for the following situation. Certain objects, such as CLLocationManager or MKReverseGeocoder, send their results asynchronously to a delegate callback method. Is it OK to release that CLLocationManager or MKReverseGeocoder instance (or whatever class it may be) in the callback method? The point is that you […]

SKStoreProductViewController rate disabled on iOS 7

So I noticed that Apple changed SKStoreProductViewController, disabling the “Write a Review” button. Is there any workaround or fix for this issue?

Can i know in viewWillAppear that it was called after navigationController pop (back button)?

Say I have UIViewController A and B. User navigates from A to B with a push segue. Than user presses back button and comes to A. Now viewWillAppear of A is called. Can I know in the code here that I came from back button (navigationController popTo…) and not by another way? And without writing […]

NSNumberFormatter Currency Without Symbol?

I am using NSNumberFormatter to get a currency value from a string and it works well. I use this code to do so: NSNumberFormatter *nf = [[NSNumberFormatter alloc] init]; [nf setNumberStyle:NSNumberFormatterCurrencyStyle]; NSString *price = [nf stringFromNumber:[NSNumber numberWithFloat:[textField.text floatValue]]]; However, it always gives me a currency symbol at the start of the string. Rather than doing […]

objective-c protocol defined in its own .h file?

Unless I’m missing something, it seems arbitrary in which .h file I put the protocol definition. I’m even wondering if it could be in it’s own .h file… (in Java, it’s in its own file)

Append NSData to a file in Objective C

I’m attempting to download a large file on the iPhone and save it to disk as it is downloaded. Ideally, in: -(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data { } I want to append ‘data’ to a file on disk. I’ve checked out the NSData documentation. There are functions to write to a file, but I can’t see anything to […]