English 中文(简体)
帮助电话电灯——超越界限错误
原标题:Help with iphone dev - beyond bounds error

我只是学习讲解语,因此,请允许我谈谈可能出现的一个小差错。 我对我的问题进行了搜索,发现了一些具体问题,因此,希望这是一个容易的解决办法。

这本书有实例,可以从数据中建立一个通过阵列硬编码的表格。 不幸的是,它从未真正告诉你如何从URL那里获取数据,因此,我不得不研究这一问题,而这正是我的问题所在。

当我去除X条码时,这似乎像算法正确,因此我不理解为什么它偏离了界限?

这是错误的信息:

2010-05-03 12:50:42.705 Simple Table[3310:20b] *** Terminating app due to uncaught exception  NSRangeException , reason:  *** -[NSCFArray objectAtIndex:]: index (1) beyond bounds (0) 

我的《危民盟》回顾以下阐述:

first,second,third,fourth

这里是一部讲解语的法典,其中引证了该书的工作实例。

#import "Simple_TableViewController.h"

@implementation Simple_TableViewController
@synthesize listData;

- (void)viewDidLoad
{
    /*
     //working code from book
     NSArray *array = [[NSArray alloc] initWithObjects:@"Sleepy", @"Sneezy", @"Bashful", @"Bashful", @"Happy",
                      @"Doc", @"Grumpy", @"Thorin", @"Dorin", @"Norin", @"Ori", @"Balin", @"Dwalin", @"Fili", @"Kili", @"Oin", 
                      @"Gloin", @"Bifur", @"Bofur", @"Bombur", nil];
     self.listData = array;
     [array release];
     */

     //code from interwebz that crashes 
     NSString *urlstr = [[NSString alloc] initWithFormat:@"http://www.mysite.com/folder/iphone-test.php"];
     NSURL *url = [[NSURL alloc] initWithString:urlstr];
     NSString *ans = [NSString stringWithContentsOfURL:url];
     NSArray *listItems = [ans componentsSeparatedByString:@","];

     self.listData = listItems;

     [urlstr release];
     [url release];
     [ans release];
     [listItems release];


    [super viewDidLoad];
}

- (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 any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.listData = nil;
    [super viewDidUnload];
}


- (void)dealloc 
{
    [listData release];
    [super dealloc];
}

#pragma mark -
#pragma mark Table View Data Source Methods

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];

    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc]
                 initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease];
    }

    NSUInteger row = [indexPath row];
    cell.textLabel.text = [listData objectAtIndex:row];
    return cell;
}

@end
最佳回答

页: 1 很可能是贵问题的项目和事项...... WHen You dont do an alloc or reservations (usually) theates sent are autoreleased, 因此,你迫切需要释放这些物体。 [NSString ...] Return an auto release string and so do the calls [ans compositionSeparatedByString:@”,].hope that helpss

问题回答

暂无回答




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签