You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I`m using the classes to load RSS news. I sued to do it in background, to save the items that I get into the app BD. The parser it calls but the functions to detect when is finished never be call. This is the code:
-(void)parseaNoticias:(NSString *)feedURLString{
@autoreleasepool {
@try {
NSURL *feedURL = [NSURL URLWithString:feedURLString];
parsedItems = [[NSMutableArray alloc] init];
alerta = [[UIAlertView alloc] initWithTitle:AMLocalizedString(@"cargando", @"")
message:@"\n"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
[alerta show];
feedParser = [[MWFeedParser alloc] initWithFeedURL:feedURL];
feedParser.delegate = self;
feedParser.feedParseType = ParseTypeFull; // Parse feed info and all items
feedParser.connectionType = ConnectionTypeAsynchronously;
[feedParser parse];
[alerta dismissWithClickedButtonIndex:0 animated:YES];
}
@catch (NSException *e){
NSLog(@"Exception %@",e);
}
}
}
#pragma mark -
#pragma mark MWFeedParserDelegate
- (void)feedParserDidStart:(MWFeedParser *)parser {
NSLog(@"Started Parsing: %@", parser.url);
}
- (void)feedParser:(MWFeedParser *)parser didParseFeedInfo:(MWFeedInfo *)info {
NSLog(@"Parsed Feed Info: “%@”", info.title);
}
- (void)feedParser:(MWFeedParser *)parser didParseFeedItem:(MWFeedItem *)item {
NSLog(@"Parsed Feed Item: “%@”", item.title);
if (item) [parsedItems addObject:item];
}
- (void)feedParserDidFinish:(MWFeedParser *)parser {
NSLog(@"Finished Parsing%@", (parser.stopped ? @" (Stopped)" : @""));
[parsedItems sortedArrayUsingDescriptors:[NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO]]];
NSString *currentL = [Global sharedMySingleton].test;
NSMutableArray *listaNoticias = [NSMutableArray array];
NSLog(@"Items parseados : %lu", (unsigned long)[parsedItems count]);
for (int i = 0; i < [parsedItems count]; i++) {
MWFeedItem *item = [parsedItems objectAtIndex:i];
if (item) {
// Process
NSString *itemTitulo = item.title ? [item.title stringByConvertingHTMLToPlainText] : @"[No Title]";
NSString *itemDescripcion= item.summary ? [item.summary stringByConvertingHTMLToPlainText] : @"[No Summary]";
NSString * itemFecha = [[NSString alloc]init];
if (item.date){
NSDateFormatter *formatter;
itemFecha = [formatter stringFromDate:item.date];
} else {
itemFecha = @"[No date]";
}
NSString * itemUrl = item.link ? :@"[No link]";
// Set
NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:@"titulo", itemTitulo, @"descripcion", itemDescripcion, @"fecha", itemFecha, @"url", itemUrl, @"idioma", currentL, nil];
NSLog(@"NOT:: %@", dict);
Noticias_DTO *noticia_dto = [[Noticias_DTO alloc]initWithNoticia:dict];
[listaNoticias addObject:noticia_dto];
}
}
//INSERTA EN LA BASE DE DATOS!!!
if ([listaNoticias count] > 0) {
Noticias_DAO *not_dao = [[Noticias_DAO alloc] init];
[not_dao InsertarNoticias:listaNoticias];
}
m_stopRunLoop = TRUE;
}
- (void)feedParser:(MWFeedParser *)parser didFailWithError:(NSError *)error {
NSLog(@"Finished Parsing With Error: %@", error);
m_stopRunLoop = TRUE;
if (parsedItems.count == 0) {
NSLog(@"No hay items que parsear"); // Show failed message in title
} else {
// Failed but some items parsed, so show and inform of error
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Parsing Incomplete"
message:@"There was an error during the parsing of this feed. Not all of the feed items could parsed."
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
}
}
- (void)dealloc {
alerta.delegate = nil;
}
What I'm doing wrong ?? I put in my .h class the delegate like this:
HI !!
I`m using the classes to load RSS news. I sued to do it in background, to save the items that I get into the app BD. The parser it calls but the functions to detect when is finished never be call. This is the code:
What I'm doing wrong ?? I put in my .h class the delegate like this:
The text was updated successfully, but these errors were encountered: