这里我有一个编码字符串的方法(它不完整),你会发现我的问题是一个错误:“指向非函数类型的块指针无效”
+ (NSString *)encodeString: (NSString *)string {
__block int indexShift;
__block NSString *dictionary = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
__block NSString *encodeDictionary = @"mahgbcjdfukripylswxovzetqnFMAJWGCQYXLOETPBKSVNIZUHDR";
__block NSString *encodeString = @"";
void (^encode) = ^{ // Error here, "Block pointer to non-function type is invalid"
for (int x = 0; x < string.length; x++) {
int index = [dictionary indexOf:[string characterAtIndex:x]];
indexShift += index;
encodeString = [encodeString stringByAppendingFormat:@"%c", [encodeDictionary characterAtIndex:index+indexShift]];
}
};
return encodeString;
}
请告诉我为什么会这样,或者我需要改变什么来解决它。