Do you mean the return value of this method?
+ (ContactInfo *)findOrCreateContact:(NSDictionary *)data inManagedObjectContext:(NSManagedObjectContext *)context
First, the designation of the state of the find OR create function, so with this name you should return the object in both cases, the one you found or just created. This will avoid confusion.
Secondly, your return type is an object, so you must return nil or an object.
So, at this point, you need to decide whether you want to keep your name or not, but let me say what you want.
You may have a method like this:
+ (ContactInfo *)findOrCreateContact:(NSDictionary *)data inManagedObjectContext:(NSManagedObjectContext *)context contactWasCreated:(BOOL *)isNew
By passing a pointer to BOOL, you can set it to YES if ContactInfo was created, and NO if you return one that already exists, and you can still return zero if you did not have ContactInfo return. Passing BOOL as a pointer is inspired by - - (BOOL)save:(NSError **)error , where you pass a pointer to an object, and you can get an NSError if necessary.
So if you could say
if (contanctInfo && wasCreated) {
You can also decide to return an NSDictionary with ContactInfo as one record and NSNumber for BOOL as another record.
source share