我正在使用单例类进行 Web 服务调用并在 uitableview 中显示,我的功能是当我单击新果园名称的提交按钮以进行新添加然后查看重定向到 tableview 但未看到最近添加的数据。“singOrchard.orcharsList”是我必须显示的果园名称数组。“[wOrchrad getorchardslist]”这是我的网络服务调用。
- (IBAction)Submit:(id)sender
{
if (Orchadname.text.length == 0) {
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"DataTree" message:@"Please Enter OrchardName" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[message show];
}
else {
[singOrchard.orcharsList removeAllObjects];
NSString *urlStr = [NSString stringWithFormat:@"http://xyz.com"]; // Passing token to URL
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self]; // Support to perform URLrequest
if (theConnection) { // checking connection successfull or not
webData1 = [NSMutableData data];
NSLog(@"Orchard Name is %@", Orchadname.text);
}
[wOrchrad getorchardslist];
NSLog(@"ARRAY COUNT %@",singOrchard.orcharsList);
[self performSelector:@selector(gotodetails) withObject:nil afterDelay:4];
}
}
"[wOrchard getorchardslist]- Singletone+Webserviceutility"
- (void)getorchardslist
{
orchardsnames = [[NSMutableArray alloc] init];
singltoneclass = [SingletoneClass sharedInstanceMethod];
theRequest =[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.xyz.com"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
webData = [NSMutableData data];
[theConnection start];
}