I am trying to set the UItextLabel from calling a web service. I am connected to the web service and can display the return "hello Frank". (the web service is super simple its just a method returning the string "hello Frank"). I can see the results in the NSLog, but I can not figure out how to set the UItextLabel on my xib. I am calling the service from the Viewcontroller class, I also used sudzc. Here is what I am trying to do below. I have been trying for days to reading/searching and simply trying to figure this out. If anyone can help/guide me in the right direction that be great. The main focus i guess would be on the handler method and the run method.
ViewController.M
Code:
// BIDViewController.m
// BIDViewController.m
// simpleTable
//
// Created by Mike Daniels on 1/9/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "BIDViewController.h"
#import "helloworldService.h"
#import "helloServices.h"
@implementation BIDViewController
@synthesize label;
@synthesize ListData;
@synthesize stringData;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
//Create the array of data for the viewcontroller lists.
NSArray *array = [[NSArray alloc] initWithObjects: @"sleepy", @"sneezy", @"bashful", @"iphone", @"hello", @"gogogogo", @"adafasdfasf", @"dfasfdfaf", @"dafdsfasfdfdddd", @"frank", @"steve", @"girl", @"sneezy", @"bashful", @"iphone", @"hello", @"gogogogo", @"adafasdfasf", @"dfasfdfaf", @"dafdsfasfdfdddd", @"frank", @"steve", @"girl", nil];
self.ListData = array;
// Do any additional setup after loading the view, typically from a nib.
helloworldService* service = [[helloworldService alloc] init];
service.logging = YES;
[service sayHello:self action:@selector(sayHelloHandler:)];
}
// Handle the response from sayHello.
- (void) sayHelloHandler: (id) value {
// Handle errors
if([value isKindOfClass:[NSError class]]) {
//NSLog(@"%@", value);
return;
}
// Handle faults
if([value isKindOfClass:[SoapFault class]]) {
//NSLog(@"%@", value);
return;
}
//Do something with the id result
self.stringData = (id)value;
NSLog(@"heres the data %@", stringData);
//[label setText: self.stringData];
}
-(UILabel *)setLabel{
label.text=(stringData);
NSLog(@"helllllllooo%@", stringData);
return label;
}
- (void)viewDidUnload
{
[self setLabel:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
self.ListData = nil;
self.stringData = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
#pragma Mark-
#pragma Mark Table View Data Source Methods
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [self.ListData count];
}
//This is where we will add in the url or anythign like that from the web service to add to the array list and put it out on the cells
-(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];
}
NSUInteger row = [indexPath row];
cell.textLabel.text =[ListData objectAtIndex:row];
return cell;
}
- (void)dealloc {
[label release];
[super dealloc];
}
@end
First, please use code brackets, otherwise reading your code is almost unbearable to read.
Second, have a uitextlable property and an nsstring property. When your webservice returns the string set your properties and your textlabels text to your string.
Hey charles thanks for checkin this out for me. I gave it a shot and still couldnt get it to print. I tried to set the label by adding another string property and setting that to it. then i also added the setText method to try that but it did not work either. can you please be a little more specific? I added the code tags and, yea ur right without that i prob wouldn't read this post either lol