App was running fine but on Xcode 6 its having error "Missing context for method declaration" on the method below:
- (NSString *)encodeBase64:(const uint8_t *)input length:(NSInteger)length{
static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
NSMutableData* data = [NSMutableData dataWithLength:((length + 2) / 3) * 4];
uint8_t* output = (uint8_t*)data.mutableBytes;
for (NSInteger i = 0; i < length; i += 3) {
NSInteger value = 0;
for (NSInteger j = i; j < (i + 3); j++) {
value <<= 8;
if (j < length) {
value |= (0xFF & input[j]);
}
}
NSInteger index = (i / 3) * 4;
output[index + 0] = table[(value >> 18) & 0x3F];
output[index + 1] = table[(value >> 12) & 0x3F];
output[index + 2] = (i + 1) < length ? table[(value >> 6) & 0x3F] : '=';
output[index + 3] = (i + 2) < length ? table[(value >> 0) & 0x3F] : '=';
}
return [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autorelease];
}
// Exact code above @end is :
/*
- (NSString *)encodeBase64:(const uint8_t *)input length:(NSInteger)length
{
#warning Replace this method.
return nil;
}
- (NSString *)decodeBase64:(NSString *)input length:(NSInteger *)length
{
#warning Replace this method.
return nil;
}
#warning Implement this function.
char* base64_encode(const void* buf, size_t size)
{ return NULL; }
#warning Implement this function.
void * base64_decode(const char* s, size_t * data_len)
{ return NULL; }
*/
@end
I ran into this issue as well. It seems to be that with Xcode6+, they don't want you putting C/C++ code inside an Objective-C context.
I moved the C/C++ code that was in the VerificationController to before the @implementation / @end block and it compiled fine after that.
I'd recommend:
a) Double-checking that your method exists in-between @implementation and @end within the file
b) Removing
- (NSString *)encodeBase64:(const uint8_t *)input length:(NSInteger)length
{
#warning Replace this method.
return nil;
}
if it still exists in the elsewhere in the file (seems to be what your comments in the original post are suggesting) ?
I had also faced the same issue with Xcode 6.0.1.
Rearranging the methods like this ( http://i.imgur.com/5TH6OaV.png ) silenced the errors ("Missing context for method declaration" and "'@end' must appear in an Objective-C context" ) for me. I hope it helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With