Skip to content

Stopping compiler warnings

briancollins edited this page Sep 13, 2010 · 1 revision

To stop compiler warnings you have to prototype all the methods that the compiler is warning you about. It is annoying but you will mostly find yourself using the same methods anyway. To prototype the methods, go to your model’s header file which should look like this:

#import <CoreData/CoreData.h>
#import "SimpleModel.h"

@interface Employee : SimpleModel {
}

@property (nonatomic, retain) NSNumber * smoker;

@end

and, below the @end tag, add the prototypes to the methods you are being warned about in a separate interface in a category of your choosing

@interface Employee (Squelch)
+ (id)findByName:(id)n;
+ (id)createWithName:(id)n;
+ (id)createWithName:(id)n dateOfBirth:(id)d starSign:(id)s;
+ (id)findByDateOfBirth:(id)d;
...
@end

Your final header file (Employee.h) should look like this:

#import <CoreData/CoreData.h>
#import "SimpleModel.h"

@interface Employee : SimpleModel {
}

@property (nonatomic, retain) NSNumber * smoker;
@property (nonatomic, retain) NSString * favoriteColor;
@property (nonatomic, retain) NSString * bloodType;

@end

@interface Employee (Squelch)
+ (id)findByName:(id)n;
+ (id)createWithName:(id)n;
+ (id)createWithName:(id)n dateOfBirth:(id)d starSign:(id)s;
+ (id)findByDateOfBirth:(id)d;
+ (id)findAllByDateOfBirth:(id)d;
+ (id)findAllByDateOfBirth:(id)d sortBy:(id)s;
+ (id)findAllByDateOfBirth:(id)d sortByDescending:(id)s;

@end

Clone this wiki locally