Reputation: 2126
I really don't understand what's going on here.
I have a function that is getting the first 3 bytes from an NSData object, receivedStream, and putting them into another NSData object, temp, via a char array. Then comparing that to an NSData object created from a char array buffer. Both new NSData objects are created and have the correct contents. However, when isEqualtoData is called, I get an error:
[NSConcreteData isEqualtoData:]: unrecognized selector sent to instance (instance refers to tmp2)
I also get the warning
Instance method '-isEqualtoData:' not found (return type defaults to 'id')
which I don't understand as it's clear that this is a valid method in the docs. Do I need to declare NSData.h somewhere?
-(BOOL)checkHeader{
char tmp[3];
[receivedStream getBytes:&tmp length:3];
NSData *temp = [NSData dataWithBytes:tmp length:3];
NSData *tmp2 = [NSData dataWithBytes:header length:3];
BOOL test = [tmp2 isEqualtoData:temp];
return test;
}
Upvotes: 14
Views: 15173
Reputation: 53551
The method is called isEqualToData:
. Note the capital T – Objective-C is case-sensitive, as most programming languages.
Upvotes: 32