IPAD must-haves. And fun-to-haves.

Brighten your iPad with a colorful cover, stream to your TV, download pictures from your digital camera, and more. There’s already so much you can do with iPad and iPad mini

Apple Wireless Keyboard

The incredibly thin Apple Wireless Keyboard uses Bluetooth technology, which makes it compatible with iPad

Apple unveils iPad mini: ‘Thin as a pencil, light as paper’

iPad inspires creativity and hands-on learning with features you won’t find in any other educational tool

Lightning connector and FaceTime HD camera

Apple announces 4th generation iPad packing an A6X CPU

Pages

Showing posts with label NSString. Show all posts
Showing posts with label NSString. Show all posts

Friday, January 11, 2013

Can't make UILabel receive NSString

I have a storyboard with a TabBar, that have two views on. On the first tab, I have one UITextField one Button and one UILabel. On the other tab, I have only one UILabel. The tho tabs (views) are controlled by the same ViewController. The thing is, with the codes I get the float value of what was inserted on the UITextField, make it into a string, and put this string on both labels, the issue is, only the label that is on the same view that the UITextField and the button that  recives the string, the other label that is on the other view don't recive anything...  

Codes:

.h

 

#import

 

@interface NotasFirstViewController : UIViewController

@property (strong, nonatomic) IBOutlet UITextField *tfield;

- (IBAction)calcular:(id)sender;

-(IBAction)clicarFora:(id)sender;

-(IBAction)tirarteclado:(id)sender;

-(IBAction)calcsecondview:(id)sender;

@property (strong, nonatomic) NSString *valorstr;

@property (strong, nonatomic) IBOutlet UILabel *mostradordeteste;

@property (strong, nonatomic) IBOutlet UILabel *mostradordetestedois;

 

@end

 

 

.m

 

#import "NotasFirstViewController.h"

#import "NotasSecondViewController.h"

 

@interface NotasFirstViewController ()

 

@end

 

@implementation NotasFirstViewController

@synthesize valorstr;

 

- (void)viewDidLoad

{

    [super viewDidLoad];

  // Do any additional setup after loading the view, typically from a nib.

}

 

- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

- (IBAction)calcular:(id)sender {

   

    float valor = [_tfield.text floatValue];

    NSString *valorstr = [[NSString alloc] initWithFormat:@"%.2f", valor];

    NSLog(@"%.2f", valor);

    NSLog(valorstr);

    _mostradordeteste.text = valorstr;

    _mostradordetestedois.text = valorstr;

   

}

 

-(IBAction)clicarFora:(id)sender{

   

    [_tfield resignFirstResponder];

   

}

-(IBAction)tirarteclado:(id)sender{

   

    [sender resignFirstResponder];

   

}

 

@end



View the original article here