0
我使用Xcode中寫了一個iPhone應用程序的登錄代碼和我的代碼似乎並沒有能夠讀取我的本地XML文件login.xml解析XML文件(的Xcode)
- (void)viewDidUnload
{
[super viewDidUnload];
users =[[NSMutableArray alloc] init];
NSString *path = [[NSBundle mainBundle] pathForResource: @"login" ofType:@"xml" inDirectory:(@"Users/roaalturki/Desktop")];
NSURL *xmlurl = [NSURL fileURLWithPath:path];
xmlparsser=[[NSXMLParser alloc] initWithContentsOfURL:xmlurl];
[xmlparsser setDelegate:self];
[xmlparsser parse];
}
-(void) parser: (NSXMLParser *) parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
currentelement=[elementName copy];
if ([elementName isEqualToString:@"username"]) {
item =[[NSMutableDictionary alloc]init];
currentuser =[[NSMutableString alloc]init];
currentpassword=[[NSMutableString alloc]init];
}
}
而錯誤信息是? - 你沒有打開文件?未能解析它?你沒有給我們太多的東西繼續下去。 – DRVic 2012-04-10 17:27:37
您確定您的應用程序包中有「Users/roaalturki/Desktop/login.xml」路徑嗎? – Sven 2012-04-10 18:19:14