1

以下のコードで、「NSData」から「NSMutableData」に割り当てられている互換性のないポインター型という警告が表示されます

-(void) connectionDidFinishLoading:(NSURLConnection *) connection
{
    NSLog(@"DONE. Received Bytes: %d", [webData length]);
    NSString *theXML = [[[NSString alloc] initWithBytes: [webData mutableBytes] length [webData length] encoding:NSUTF8StringEncoding] autorelease];

    theXML = [theXML stringByReplacingOccurrencesOfString:@"&lt;" withString:@"<"];
    theXML = [theXML stringByReplacingOccurrencesOfString:@"&gt;" withString:@">"];
    NSLog(@"%@",theXML);

    if( xmlParser )
    {
        xmlParser = nil;
        [xmlParser release];
    }

    NSMutableString *str = [[NSMutableString alloc]initWithString:theXML];
    webData = [str dataUsingEncoding:NSUTF16StringEncoding];//WARNING

    xmlParser = [[[NSXMLParser alloc] initWithData:webData] autorelease];
    [xmlParser setDelegate:self];
    [xmlParser setShouldResolveExternalEntities: YES];
    [xmlParser parse];

    [connection release];
}
4

2 に答える 2

5

使用する

webData = [NSMutableData dataWithData:[str dataUsingEncoding:NSUTF16StringEncoding]];
于 2012-05-09T10:31:45.597 に答える