有人可以告诉我我需要做什么来解决这个问题
这是错误消息。
将'NSMutableString * _strong'传递给'NSNumber
类型参数的指针类型不兼容 - (void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
if ([elementName isEqualToString:@"User"]) {
inItemElement = YES;
}
if (inItemElement && [elementName isEqualToString:@"myxmluseridnumber"]) {
capturedCharacters = [[NSMutableString alloc] initWithCapacity:100];
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if(capturedCharacters != nil) {
[capturedCharacters appendString:string];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
if (inItemElement && [elementName isEqualToString:@"myxmluseridnumber"]) {
NSLog(@"%@ - myxmlnumber", capturedCharacters);
//This is what is producing my error
userpref.userid = capturedCharacters;
capturedCharacters = nil;
}
if ([elementName isEqualToString:@"User"]) {
inItemElement = NO;
}
}
由于
答案 0 :(得分:1)
由于用户ID是NSNumber
,您应该从字符串NSNumber
capturedCharacters
userpref.userid = [NSNumber numberWithInt:[capturedCharacters 的intValue]];
答案 1 :(得分:0)
用以下代码替换错误产生线:
userpref.userid = [capturedCharacters intValue];
(假设您的capturedCharacters
是s NSString
)