Error Message: Incompatible pointer to integer conversion sending 'NSArray *__strong' to parameter of type 'NSUInteger'

StackOverflow https://stackoverflow.com/questions/22816110

Domanda

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];
È stato utile?

Soluzione

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:]).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top