0
我有一個類(核心數據生成):分類實例方法不調用
@interface Place : NSManagedObject
@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) NSString * subtitle;
@property (nonatomic, retain) NSNumber * latitude;
@property (nonatomic, retain) NSNumber * longitude;
@end
@implementation Place
@dynamic title;
@dynamic subtitle;
@dynamic latitude;
@dynamic longitude;
@end
ADN它的類別:
@interface Place (Create)
+ (Place *)placeWithTitle:(NSString *)title
inManagedObjectContext:(NSManagedObjectContext *)context;
+(Place *) placeWithTitle:(NSString *)title andSubtitle:(NSString *)subtitle inManagedObjectContext:(NSManagedObjectContext *)context;
+(Place *) placeWithCoordinate:(CLLocationCoordinate2D) coordinate inManagedObjectContext:(NSManagedObjectContext *)context;
- (void) setLattitudeAndLongitudeByCoordinate:(CLLocationCoordinate2D) coordinate;
- (CLLocationCoordinate2D) coordinate;
@end
在這個類別中有實例方法:
- (void) setLattitudeAndLongitudeByCoordinate:(CLLocationCoordinate2D) coordinate
{
self.latitude=[NSNumber numberWithDouble:coordinate.latitude];//break point HERE
self.longitude=[NSNumber numberWithDouble:coordinate.longitude];
}
-(CLLocationCoordinate2D) coordinate
{
CLLocationCoordinate2D coord;//break point HERE
coord.latitude=[self.latitude doubleValue];
coord.longitude=[self.longitude doubleValue];
return coord;
}
正如你所看到的我必須在那裏斷點。現在,然後我調用這些方法
#import "Place+Create.h"
-(void)someMethod
{
[self.place setLattitudeAndLongitudeByCoordinate:coordiante];
}
它似乎從來沒有達到法setLattitudeAndLogitudeByCoordinate內的斷點, 和調試表明,它甚至不給他們打電話!爲什麼?
'someMethod'是否到達過?如果不是,那麼你的問題就在別的地方。如果達到了,那麼'self.place'顯然是'nil'。 – Till 2012-04-18 16:30:30
沒錯,解決它。謝謝! – 2012-04-18 16:56:55
我在答覆中重複了這一點,以防止此問題未得到答覆。 – Till 2012-04-18 17:33:32