无法从RSS - Xcode中提取信息

时间:2011-08-18 19:02:00

标签: iphone objective-c rss xcode

我构建了一个应用程序,我离开Rss结束,当我构建它时,一切正常,除了我看不到来自rss的信息,我可以在表视图中看到标题,但我可以看不到图像,标题和描述。 请在这件事上给予我帮助, 谢谢提前, 约翰

(该应用程序基于:基于视图的应用程序!) 另外,我附上我的代码:

-(void)reloadRss{   
    [self toggleToolBarButtons:NO];     
    [[self rssParser]startProcess]; 
}

-(void)toggleToolBarButtons:(BOOL)newState{     
    NSArray *toolbarItems = self.toolbar.items;     
    for (UIBarButtonItem *item in toolbarItems){
        item.enabled = newState;    
    }    
}

//Delegate method for blog parser will get fired when the process is completed
- (void)processCompleted{   
    //reload the table view     
    [self toggleToolBarButtons:YES];    
    [[self tableView]reloadData]; 
}

-(void)processHasErrors{    
    //Might be due to Internet  
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"The" message:@"איןאפשרות להוריד מידע.                                             אנאבדוק את חיבור האינטרנט שלך." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];    
    [alert show];       
    [alert release];    
    [self toggleToolBarButtons:YES]; 
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{   
    return [[[self rssParser]rssItems]count]; 
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{     
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"rssItemCell"];
    if(nil == cell){        
        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"rssItemCell"]autorelease];     
    }   
    cell.textLabel.text = [[[[self rssParser]rssItems]objectAtIndex:indexPath.row]title];
    cell.detailTextLabel.text = [[[[self rssParser]rssItems]objectAtIndex:indexPath.row]description];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell; 
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [[self viewController] setCurrentlySelectedBlogItem:[[[self rssParser]rssItems]objectAtIndex:indexPath.row]];   
    [self.view addSubview:newsr];

}
-(IBAction)rss{
    [self.view addSubview:rss]; 
}

- (void)viewDidUnload {
    [super viewDidUnload];


    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil; }

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait); }


-(void)openWebLink{     // open a dialog with an OK and cancel button
    UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"האם אתה רוצה לפתוח דף זה ב-Safari ?" delegate:self cancelButtonTitle:@"בטל" destructiveButtonTitle:@"אשר" otherButtonTitles:nil];
    actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
    [actionSheet showFromToolbar:_toolbar];     
    [actionSheet release];   
}


- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{   
    if(buttonIndex == 0){
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[[[self viewController] currentlySelectedBlogItem]linkUrl]]];   
    } 
}

- (void)viewWillAppear:(BOOL)animated{  
    [super viewWillAppear:animated];    
    NSString * mediaUrl = [[[self viewController]currentlySelectedBlogItem]mediaUrl];   
    [[self image]setImage:[UIImage imageNamed:@"unknown.jpg"]];     
    if(nil != mediaUrl){        
        NSData* imageData;      
        [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;        
        @try {
            imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:mediaUrl]];
        }       
        @catch (NSException * e) {          
            //Some  error while downloading data        
        }       
        @finally {          
            UIImage * imageFromImageData = [[UIImage alloc] initWithData:imageData];
            [[self image]setImage:imageFromImageData];          
            [imageData release];
            [imageFromImageData release];       
        }       
        [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;    
    }
    self.titleTextView.text = [[[self viewController] currentlySelectedBlogItem]title];
    self.descriptionTextView.text = [[[self viewController] currentlySelectedBlogItem]description];    
}


@end

1 个答案:

答案 0 :(得分:0)

尝试使用以下内容解码RSS的内容:

NSWindowsCP1252StringEncoding

NSUTF8StringEncoding

...