Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-10-2012, 04:15 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 3
stimy24 is on a distinguished road
Default set UItextLabel from web service

Hi All,

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
viewcontroller.h
Code:
#import <UIKit/UIKit.h>

@interface BIDViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>{
    
}

@property (strong, nonatomic) NSArray *ListData;
@property (strong, nonatomic) NSString *stringData;
@property (nonatomic, retain) IBOutlet UILabel *label;
@end

Last edited by stimy24; 01-10-2012 at 10:37 PM.
stimy24 is offline   Reply With Quote
Old 01-10-2012, 08:48 PM   #2 (permalink)
Registered Member
 
newDev's Avatar
 
Join Date: Jul 2010
Location: Utah
Posts: 75
newDev is on a distinguished road
Default

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.

Hope that helps.
__________________
Sir Charles Barkley
newDev is offline   Reply With Quote
Old 01-10-2012, 10:41 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 3
stimy24 is on a distinguished road
Default

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

--Thanks
stimy24 is offline   Reply With Quote
Reply

Bookmarks

Tags
service, sudzc, web, web service

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 385
10 members and 375 guests
Atatator, buggen, guusleijsten, j.b.rajesh@gmail.com, morterbaher, QuantumDoja, sacha1996, Sami Gh, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:36 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0