Ios NSXMLParser和搜索栏
在成功地从服务器请求和解析xml文件之后,我想在顶部添加一个小搜索栏。因此,在我学习Objective ci时,我学习了3到4个关于如何制作功能搜索栏的教程,但没有成功。问题是我不知道如何在NSXMLParser填充的NSMutableArray中执行排序,我寻求帮助,请: 这是我打印结果的地方:Ios NSXMLParser和搜索栏,ios,objective-c,nsxmlparser,Ios,Objective C,Nsxmlparser,在成功地从服务器请求和解析xml文件之后,我想在顶部添加一个小搜索栏。因此,在我学习Objective ci时,我学习了3到4个关于如何制作功能搜索栏的教程,但没有成功。问题是我不知道如何在NSXMLParser填充的NSMutableArray中执行排序,我寻求帮助,请: 这是我打印结果的地方: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPa
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
CGRect frame = CGRectMake(0, 0, 160, 50);
UILabel *lbl1 = [[UILabel alloc] initWithFrame:frame];
lbl1.textAlignment = NSTextAlignmentRight;
[lbl1 setFont:[UIFont fontWithName:@"Helvetica" size:12.0]];
[lbl1 setTextColor:[UIColor grayColor]];
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
lbl1.text = [[stories objectAtIndex: storyIndex] objectForKey: @"creation_date"];
[cell.contentView addSubview:lbl1];
[lbl1 release];
CGRect frame2 = CGRectMake(0, 0, 250, 50);
UILabel *lbl2 = [[UILabel alloc] initWithFrame:frame2];
lbl2.textAlignment = NSTextAlignmentRight;
[lbl2 setFont:[UIFont fontWithName:@"Helvetica" size:12.0]];
[lbl2 setTextColor:[UIColor blackColor]];
lbl2.text = [[stories objectAtIndex: storyIndex] objectForKey: @"name"];
[cell.contentView addSubview:lbl2];
[lbl2 release];
if(!uploaded)
{
CGRect frame2 = CGRectMake(48, 12, 250, 50);
UILabel *lbl2 = [[UILabel alloc] initWithFrame:frame2];
lbl2.textAlignment = NSTextAlignmentLeft;
[lbl2 setFont:[UIFont fontWithName:@"Helvetica" size:10.0]];
[lbl2 setTextColor:[UIColor blueColor]];
lbl2.text = [[stories objectAtIndex: storyIndex] objectForKey: @"owner_name"];
[cell.contentView addSubview:lbl2];
[lbl2 release];
}
return cell;
}
查看以下链接上的类似帖子,您可以使用NSArray(NSMutableArray的超类)方法对数组进行排序:
–sortedarrayint
–sortedarraying功能:上下文:
–sortedarraying功能:上下文:提示:
–sortedarraying描述符:
–sortedarraying选择器:
sortedarraying比较器:–sortedarraying选项:使用比较器:是的,谢谢:D!如果你想,你可以编辑一个答案,我会把它评为好答案。