gpt4 book ai didi

ios - 缺少方法声明的上下文 - 应用内收据 verificationController

转载 作者:可可西里 更新时间:2023-11-01 03:07:07 25 4
gpt4 key购买 nike

应用程序运行良好,但在 Xcode 6 上,它在以下方法中出现错误“方法声明缺少上下文”:

- (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

最佳答案

我也遇到了这个问题。似乎对于 Xcode6+,他们不希望您将 C/C++ 代码放在 Objective-C 上下文中。

我将 VerificationController 中的 C/C++ 代码移动到 @implementation/@end block 之前,之后编译正常。

关于ios - 缺少方法声明的上下文 - 应用内收据 verificationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25869952/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com