1
votes

I'm converting my iOS 6 app to work in iOS 7. It uses CoreData and in my model I have a few entities and attributes defined. One of the attributes is a deliveryid and the type is set to Integer 32.

I have NSManagedObject classes created for my core data entities and these worked fine previously in XCode 5 with iOS 6.

When I bring those NSManagedObject classes over to target iOS 7 I get the error "Incompatible pointer to integer conversion sending 'NSNumber *' to parameter of type 'long'".

For the deliveryid attribute it is defined as follows in the .h file:

@property (nonatomic, strong) NSNumber * deliveryid;

then in the .m file I have:

NSString *strDeliveryID = [[NSNumber numberWithLong:self.deliveryid] stringValue];

where I try to convert to a string value. This previously didn't create any warnings or issues when compiled.

I am unable to solve why the issue is appearing for iOS 7. Can somebody help please?

2
This is not related either to Xcode nor to Core Data. You should learn the language better, then read the compiler error and think about what it means.user529758

2 Answers

4
votes

self.deliveryid is already an NSNumber*. There is no reason to create a new NSNumber* out of it. Use this:

NSString *strDeliveryID = self.deliveryid.stringValue;

Another option is the following, which is silly and confusing:

NSString *strDeliveryID = @(self.deliveryid.longValue).stringValue;
2
votes

You can try :

NSString *strDeliveryID = [NSString stringWithFormat:@"%@",deliveryid];