使用从JSON文件下载数据的表视图时遇到问题。 JSON有4个条目,我希望我的代码忽略第一个条目,只需将第一个条目放入表格视图中。使用下面的代码,它将从JSON获取完整的4个条目并将它们全部放入表视图中。我已经尝试了一切,但似乎无法解决这个问题。
谢谢,
CurtisB
#import "TutorProfileView.h"
@interface TutorProfileView ()
@end
@implementation TutorProfileView
NSDictionary *TutordizDict = @"";
NSMutableArray *TutordaObj;
NSDictionary *Tutordadict;
NSArray *Tutortrackinbud;
- (void)viewDidLoad {
[super viewDidLoad];
[self downloadreviews];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSArray *udropofftrack = [TutordizDict objectForKey:@"tutific"];
return [udropofftrack count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 88;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"TableViewCell2";
TableViewCell2 *cell = (TableViewCell2 *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:@"TableViewCell2" owner:self options:nil];
cell = [nibArray objectAtIndex:0];
}
cell.name.text = [NSMutableString stringWithFormat:@"%@",[Tutortrackinbud[indexPath.row] valueForKey:@"username"]];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
-(void)downloadreviews
{
NSString *subjects2 = @"tutor1";
NSURL *blogURL = [NSURL URLWithString:[NSString stringWithFormat:@"getreviews.php?username=%@", subjects2]];
NSLog(@"URL = %@", blogURL);
NSData *jsonData = [NSData dataWithContentsOfURL:blogURL];
if(jsonData == nil)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Error" message:@"Please check your internet connection and try again." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
return;
}
else{
NSError *error = nil;
TutordizDict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
Tutortrackinbud = [TutordizDict objectForKey:@"tutific"];
NSUInteger *elements = [Tutortrackinbud count];
NSLog(@"Number of Shows : %d", elements);
if (elements == 0)
{
//[udropofftrack removeAllObjects];
Tutortrackinbud=nil;
[_tableViewObject reloadData];
// self.noorder.hidden=FALSE;
}
else{
NSString *success = [Tutortrackinbud[0] valueForKey:@"success"];
if ([success isEqual: @"0"])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Error" message:@"Your application failed to connect to uDropOff servers. Please update your application in the App Store." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
return;
}
else
{
{
for (int i = 1 ; i < [Tutortrackinbud count]; i++){
{
TutordaObj = [[NSMutableArray alloc] init];
}
}
}
}
}
}
[_tableViewObject reloadData];
}
@end
答案 0 :(得分:1)
如果我正确理解你的问题,你只想跳过数组中的第一个元素/条目。为什么不使用[element = driver.findElement(By.partialLinkText("signin")).click();]
样品:
Tutortrackinbud