我正在使用單一類的web服務調用和顯示在uitableview中,我的功能是當我點擊提交按鈕的新的orchardname新添加然後查看重定向到tableview,但數據不是看到最近添加的。 「singOrchard.orcharsList」它是我必須展示的果園名稱數組。 「[wOrchrad getorchardslist]」這是我的web服務調用。如何顯示在按鈕點擊uitableview上的網頁json數據
- (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];
}
可以添加代碼方法[wOrchrad getorchardslist]; – suhit
我添加了我的詳細信息,請檢查 – Rohan1001