Hi,
I am using the code below to call data using PHP from my web site, her is my NSObject code .h:
-(instancetype)initWithId:(int)Id Name:(NSString *)currentName City:(NSString
*)givenCity Address:(NSString *)givenAddress;
@property (nonatomic) int Id;
@property (nonatomic,strong) NSString * city;
@property (nonatomic,strong) NSString * name;
@property (nonatomic,strong) NSString *address;
Her is my NSObject code .m:
-(instancetype)initWithId:(int)Id Name:(NSString *)currentName City:(NSString
*)givenCity Address:(NSString *)givenAddress{
self = [super init];
if(self){
self.Id = Id;
self.name = currentName;
self.city = givenCity;
self.address = givenAddress;
}
return self;
}
Her is where I call the data:
NSURL *blogURL = [NSURL URLWithString:JSON_URL];
NSData *jsonData = [NSData dataWithContentsOfURL:blogURL];
NSError *error = nil;
NSDictionary *dataDictionary = [NSJSONSerialization
JSONObjectWithData:jsonData options:0 error:&error];
for (NSDictionary *bpDictionary in dataDictionary) {
HotelObject *currenHotel = [[HotelObject alloc]initWithId:[[bpDictionary
objectForKey:@"timeLineVideoUserName"]integerValue] Name:[bpDictionary objectForKey:@"timeLineVideoUserName"]
// in the line above the Xcode shows this message:
Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int.
City:[bpDictionary objectForKey:@"timeLineVideoUserName"] Address:[bpDictionary
objectForKey:@"timeLineVideoDetails"]];
[self.objectHolderArray addObject:currenHotel];
}
How can I solve this problem?