gpt4 book ai didi

ios - 从NSData获得警告不兼容的指针类型分配给'NSMutableData'

转载 作者:行者123 更新时间:2023-12-01 17:34:01 26 4
gpt4 key购买 nike

我在以下代码中得到警告::不兼容的指针类型从'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];
}

最佳答案


webData = [NSMutableData dataWithData:[str dataUsingEncoding:NSUTF16StringEncoding]];

关于ios - 从NSData获得警告不兼容的指针类型分配给'NSMutableData',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10514100/

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