views:

44

answers:

1

I'm getting this warning "Format not a string literal and no format arguments? Any ideas?

-(BOOL)isFirstPointReached{

    NSString *firstPoint = [NSString stringWithFormat:[pointsToFillArray objectAtIndex:0]];
    NSString *lastPoint = [NSString stringWithFormat:[pointsToFillArray lastObject]];

    if([firstPoint isEqualToString:lastPoint]){

        return YES;
    }

    else{ 

        return NO;
    }
}
+4  A: 

A few points...

The pointsToFillArray is an array of objects and the compiler does not know if it contains NSStrings or any other type of object. To get rid of the error you would cast it to (NSString*)

Secondly, the stringWithFormat is normally used to create a string from a few different pieces of data and does not need to be used in this case

Thirdly, you could just create pointers to the objects within the array and then do your check

The following should work for you:

NSString *firstPoint = (NSString*)[pointsToFillArray objectAtIndex:0];
NSString *lastPoint = (NSString*)[pointsToFillArray lastObject];

if ([firstPoint isEqualToString:lastPoint]) {
   return YES;
}
Liam