Why am I getting this issue error?
Incompatible pointer to integer conversion sending 'NSArray *__strong' to parameter of type 'NSUInteger'
#import "FSConverter.h"
#import "FSVenue.h"
@implementation FSConverter
- (NSArray *)convertToObjects:(NSArray *)venues {
NSMutableArray *objects = [NSMutableArray arrayWithCapacity:venues];
for (NSDictionary *v in venues) {
FSVenue *ann = [[FSVenue alloc]init];
ann.name = v[@"name"];
ann.venueId = v[@"id"];
ann.location.address = v[@"location"][@"address"];
ann.location.distance = v[@"location"][@"distance"];
[ann.location setCoordinate:CLLocationCoordinate2DMake([v[@"location"][@"lat"] doubleValue],
[v[@"location"][@"lng"] doubleValue])];
[objects addObject:ann];
}
return objects;
}
@end
The error is on this line:
NSMutableArray *objects = [NSMutableArray arrayWithCapacity:venues];
It's because [NSMutableArray arrayWithCapacity:]
expects an integer, and not an array, as an argument.
Assuming you want to create a mutable array with the same initial capacity as the array passed-in, then you probably meant:
NSMutableArray *objects = [NSMutableArray arrayWithCapacity:venues.count];
or simply:
NSMutableArray *objects = [NSMutableArray new];
(and forget about the initial capacity, given you are using [objects addObject:]
).