result out put

//
//  ViewController.m
//  MyApplication2
//
//  Created by Local Admin on 7/8/56 BE.
//  Copyright (c) 2556 Local Admin. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize myLebel;
@synthesize myText;
- (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)myButton:(id)sender {
    NSString * ss=@"hello ";
    ss=[ss stringByAppendingString:myText.text];
    myLebel.text=ss;
}

@end

 

//
//  ViewController.h
//  MyApplication2
//
//  Created by Local Admin on 7/8/56 BE.
//  Copyright (c) 2556 Local Admin. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *myText;
@property (weak, nonatomic) IBOutlet UILabel *myLebel;
- (IBAction)myButton:(id)sender;

@end

ถ้าต้องการตรวจสอบ length ของ textbox ให้ใช้ตามนี้

   NSString * s=myText.text;
    if([s length]==0)
    {

    }

อะไรที่เป็น pointer จะใช้ วรรค สังเกตุถ้า * จะมีวรรคตรง  s length

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.