得到错误:Xcode中的'*'标记之前预期':'

时间:2011-10-21 08:59:52

标签: iphone objective-c xcode

我正试图从http://www.raywenderlich.com/2636/how-to-make-a-simple-rss-reader-iphone-app-tutorial中删除一个RSSFeed应用程序。一切顺利,直到发生此错误。我已经检查了教程代码中的所有内容但找不到任何内容。我已按原样复制了代码。我一直困在这里想摆脱它,所以我可以走得更远工作完成。我在下面放一段代码。请任何人都可以帮助我。                         thnx提前..

//  RootViewController.m
//  RSSFun

#import "GDataXMLNode.h"
#import "GDataXMLElement-Extras.h"
#import "ASIHTTPRequest.h"
#import "RSSEntry.h"
#import "RootViewController.h"


@implementation RootViewController
@synthesize feeds = _feeds;
@synthesize queue = _queue;

@synthesize allEntries = _allEntries;

- (void)refresh {
for (NSString *feed in _feeds) {
    NSURL *url = [NSURL URLWithString:feed];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];
    [_queue addOperation:request];
}    
}

- (void)addRows {    
RSSEntry *entry1 = [[[RSSEntry alloc] initWithBlogTitle:@"1" 
                                           articleTitle:@"1" 
                                             articleUrl:@"1" 
                                            articleDate:[NSDate date]] autorelease];
RSSEntry *entry2 = [[[RSSEntry alloc] initWithBlogTitle:@"2" 
                                           articleTitle:@"2" 
                                             articleUrl:@"2" 
                                            articleDate:[NSDate date]] autorelease];
RSSEntry *entry3 = [[[RSSEntry alloc] initWithBlogTitle:@"3" 
                                           articleTitle:@"3" 
                                             articleUrl:@"3" 
                                            articleDate:[NSDate date]] autorelease];    

[_allEntries insertObject:entry1 atIndex:0];
[_allEntries insertObject:entry2 atIndex:0];
[_allEntries insertObject:entry3 atIndex:0];        
}

- (void)viewDidLoad {
[super viewDidLoad];    
self.title = @"Feeds";
self.allEntries = [NSMutableArray array];
self.queue = [[[NSOperationQueue alloc] init] autorelease];
self.feeds = [NSArray arrayWithObjects:@"http://feeds.feedburner.com/RayWenderlich",
              @"http://feeds.feedburner.com/vmwstudios",
              @"http://idtypealittlefaster.blogspot.com/feeds/posts/default", 
              @"http://www.71squared.com/feed/",
              @"http://cocoawithlove.com/feeds/posts/default",
              @"http://feeds2.feedburner.com/brandontreb",
              @"http://feeds.feedburner.com/CoryWilesBlog",
              @"http://geekanddad.wordpress.com/feed/",
              @"http://iphonedevelopment.blogspot.com/feeds/posts/default",
              @"http://karnakgames.com/wp/feed/",
              @"http://kwigbo.com/rss",
              @"http://shawnsbits.com/feed/",
              @"http://pocketcyclone.com/feed/",
              @"http://www.alexcurylo.com/blog/feed/",         
              @"http://feeds.feedburner.com/maniacdev",
              @"http://feeds.feedburner.com/macindie",
              nil];    
[self refresh];
}


 /*
 - (void)viewDidLoad {
[super viewDidLoad];

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
*/

/*
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
*/

/*
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
*/

 /*

- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
*/

 /*
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
*/

/*
 // Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
 */

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release anything that can be recreated in viewDidLoad or on demand.
// e.g. self.myOutlet = nil;
}

- (void)requestFinished:(ASIHTTPRequest *)request {
//Error occurs here
[_queue addOperationWithBlock:^
{

    NSError *error;
    GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:[request responseData] 
                                                           options:0 error:&error];
    if (doc == nil) { 
        NSLog(@"Failed to parse %@", request.url);
    } else {

        NSMutableArray *entries = [NSMutableArray array];
        [self parseFeed:doc.rootElement entries:entries];                

        [[NSOperationQueue mainQueue] addOperationWithBlock:^{

            for (RSSEntry *entry in entries) {

                int insertIdx = 0;                    
                [_allEntries insertObject:entry atIndex:insertIdx];
                [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:insertIdx inSection:0]]
                 withRowAnimation:UITableViewRowAnimationRight];

            }                            

        }];

    }        
}];

}

- (void)requestFailed:(ASIHTTPRequest *)request {
NSError *error = [request error];
NSLog(@"Error: %@", error);
}

- (void)parseFeed:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {    
if ([rootElement.name compare:@"rss"] == NSOrderedSame) {
    [self parseRss:rootElement entries:entries];
} else if ([rootElement.name compare:@"feed"] == NSOrderedSame) {                       
    [self parseAtom:rootElement entries:entries];
} else {
    NSLog(@"Unsupported root element: %@", rootElement.name);
}    
}

- (void)parseRss:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {

NSArray *channels = [rootElement elementsForName:@"channel"];
for (GDataXMLElement *channel in channels) {            

    NSString *blogTitle = [channel valueForChild:@"title"];                    

    NSArray *items = [channel elementsForName:@"item"];
    for (GDataXMLElement *item in items) {

        NSString *articleTitle = [item valueForChild:@"title"];
        NSString *articleUrl = [item valueForChild:@"link"];            
        NSString *articleDateString = [item valueForChild:@"pubDate"];        
        NSDate *articleDate = nil;

        RSSEntry *entry = [[[RSSEntry alloc] initWithBlogTitle:blogTitle 
                                                  articleTitle:articleTitle 
                                                    articleUrl:articleUrl 
                                                   articleDate:articleDate] autorelease];
        [entries addObject:entry];

    }      
}

}

- (void)parseAtom:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {

NSString *blogTitle = [rootElement valueForChild:@"title"];                    

NSArray *items = [rootElement elementsForName:@"entry"];
for (GDataXMLElement *item in items) {

    NSString *articleTitle = [item valueForChild:@"title"];
    NSString *articleUrl = nil;
    NSArray *links = [item elementsForName:@"link"];        
    for(GDataXMLElement *link in links) {
        NSString *rel = [[link attributeForName:@"rel"] stringValue];
        NSString *type = [[link attributeForName:@"type"] stringValue]; 
        if ([rel compare:@"alternate"] == NSOrderedSame && 
            [type compare:@"text/html"] == NSOrderedSame) {
            articleUrl = [[link attributeForName:@"href"] stringValue];
        }
    }

    NSString *articleDateString = [item valueForChild:@"updated"];        
    NSDate *articleDate = nil;

    RSSEntry *entry = [[[RSSEntry alloc] initWithBlogTitle:blogTitle 
                                              articleTitle:articleTitle 
                                                articleUrl:articleUrl 
                                               articleDate:articleDate] autorelease];
    [entries addObject:entry];

}      

}


#pragma mark Table view methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section              {
return [_allEntries count];

}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}

RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];

NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSString *articleDateString = [dateFormatter stringFromDate:entry.articleDate];

cell.textLabel.text = entry.articleTitle;        
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ - %@", articleDateString, entry.blogTitle];

return cell;

}


/*

// Override to support row selection in the table view.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

// Navigation logic may go here -- for example, create and push another view controller.
// AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
// [self.navigationController pushViewController:anotherViewController animated:YES];


// [anotherViewController release];
}
*/
/*

// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {

 // Return NO if you do not want the specified item to be editable.
return YES;
}

*/


/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

if (editingStyle == UITableViewCellEditingStyleDelete) {
    // Delete the row from the data source.
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}   
else if (editingStyle == UITableViewCellEditingStyleInsert) {
    // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}   
}

*/


/*

  // Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
 }
*/




 // Override to support conditional rearranging of the table view.
    - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {

 // Return NO if you do not want the item to be re-orderable.
return YES;
}

 */


- (void)dealloc {
[super dealloc];
[_allEntries release];
_allEntries = nil;
[_queue release];
_queue = nil;
[_feeds release];
_feeds = nil;


}


@end

2 个答案:

答案 0 :(得分:3)

在你的dealloc方法之前,你有一个虚假的* /需要删除。

答案 1 :(得分:0)

enter code here在文件末尾,您有以下内容:

 // Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {



// Return NO if you do not want the item to be re-orderable.
return YES;
}

 */

应删除最后一个结束注释块* /因为它没有开始块。离去:

// Override to support conditional rearranging of the table view.
    - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {



    // Return NO if you do not want the item to be re-orderable.
    return YES;
    }