So I have a class with a NSInteger in it and now I want to return the NSInteger value. For some kind开发者_JS百科 of reason, the code for that is not working. I have already declared the @property for the NSInteger class.
@property (readwrite, assign, nonatomic) NSInteger numberFun;
- (NSInteger)sampleMethod {
...
return sample.numberFun;
}
The compiler says "Return from pointer without a cast". I'm pretty sure that means that I'm using a C type for an objective-c method. I want to know the work around for this. (Though I don't want it to return a casted NSInteger as a NSNumber).
Thanks
The following code sample compiles fine. I suggest you present a more complete example of your problem so we can figure out what you are doing wrong.
@interface MyObject : NSObject
{ }
@property (readwrite, assign, nonatomic) NSInteger numberFun;
@end
@implementation MyObject
@synthesize numberFun;
@end
@interface MyObject2 : NSObject
{ }
@property (nonatomic, copy) MyObject* sample;
@end
@implementation MyObject2
@synthesize sample;
- (NSInteger)sampleMethod { return sample.numberFun; }
@end
精彩评论