NSData + Base64.m中的XCode标记类型错误

时间:2012-10-20 13:55:47

标签: iphone objective-c ios

错误如下图所示 enter image description here

- (id) initWithBase64EncodedString:(NSString *) string {
    NSMutableData *mutableData = nil;

    if( string ) {
        unsigned long ixtext = 0;
        unsigned long lentext = 0;
        unsigned char ch = 0;
        unsigned char inbuf[4], outbuf[4];
        short i = 0, ixinbuf = 0;
        BOOL flignore = NO;
        BOOL flendtext = NO;
        NSData *base64Data = nil;
        const unsigned char *base64Bytes = nil;

        // Convert the string to ASCII data.
        base64Data = [string dataUsingEncoding:NSASCIIStringEncoding];
        base64Bytes = [base64Data bytes];
        mutableData = [NSMutableData dataWithCapacity:[base64Data length]];
        lentext = [base64Data length];

    }

而且我正在使用另一种名为

的方法
- (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength {
    **const unsigned char   *bytes = [self bytes];**
    NSMutableString *result = [NSMutableString stringWithCapacity:[self length]];

} enter image description here

1 个答案:

答案 0 :(得分:1)

您可以通过类型转换解决该错误...但不确定数据是否在同一格式中。

    base64Bytes = (const unsigned char*)[base64Data bytes];