나는 nsxml 파서에서 일하고 있으며 몇 가지 문제점이 있습니다. nsxml 파서를 사용하여 날짜를 구문 분석합니다 .2 일만의 정보를 얻고 싶습니다. Google 날씨 api에서 모두 4 개. 어떻게해야합니까?nsxml 날짜를 파서에서 일치시키고 필요한 날짜 만 얻는 방법
NSMutableArray *array=[NSMutableArray arrayWithObjects:startDate,endDate,Nil];
for (NSDate *date in array)
{
if([date isEqualToDate:dd])
{
NSManagedObject *allnew = Nil;
NSManagedObjectContext *allone=[self managedObjectContext];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Weather" inManagedObjectContext:allone];
NSLog(@" The NEW ENTITY IS ALLOCATED AS entity is %@",entity);
WeatherXMLParser *delegate = [[WeatherXMLParser alloc] initWithCity:city state:state country:country];
NSXMLParser *locationParser = [[NSXMLParser alloc] initWithContentsOfURL:delegate.url];
[locationParser setDelegate:delegate];
[locationParser setShouldResolveExternalEntities:YES];
[locationParser parse];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entity];
predicate = [NSPredicate predicateWithFormat:
@"city == %@ and state == %@ and country == %@ and date==%@ and date==%@", city, state, country,startDate,endDate];
[request setPredicate:predicate];
NSError *err;
NSUInteger count = [allone countForFetchRequest:request error:&err];
NSLog(@" minimum salary is %@",predicate);
// If a predicate was passed, pass it to the query
if(predicate !=NULL){
[self deleteobject];
}
Weather *weather = (Weather *)[NSEntityDescription insertNewObjectForEntityForName:@"Weather"
inManagedObjectContext:self.managedObjectContext];
weather.date = [fields objectForKey:@"date"];
weather.high =[fields objectForKey:@"high"];
weather.low = [fields objectForKey:@"low"];
weather.city =[fields objectForKey:@"city"];
weather.state =[fields objectForKey:@"state"];
weather.country =[fields objectForKey:@"country"];
NSString*icon=[fields objectForKey:@"icon"];
NSString *all=[icon lastPathComponent];
weather.condition = all;
[self saveContext];
}
파서의 파일을 nsdictionary에 저장합니다. – iphone
구문 분석 할 실제 XML 형식을 언급했습니다. 그럼에도 불구하고 플래그/카운터를 만들고 단순히 구문 분석하지 않는 것이 문제를 해결해야합니다. –
당신은 나에게 더미 코드를 보여줄 수 있습니까? 나는 그물에 어떤 예를 찾을 수 없습니다. 나는 매우 새로운 목적 c에 있습니다. – iphone