首页 > 其他 > 详细

使用结构中的成员变量在oc 中进行数据传递

时间:2016-01-21 23:22:47      阅读:152      评论:0      收藏:0      [点我收藏+]

//

//  ViewController.m

//  tttttttt

//

//  Created by 张凯泽 on 16/1/20.

//  Copyright © 2016年 rytong_zkz. All rights reserved.

//

 

#import "ViewController.h"

typedef struct {

    char * name;

    char * sex;

    int age;

}Person;

@interface ViewController ()

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

    Person p;

    p.name = "zkz";

    p.age = 34;

    p.sex = "nan";

    //printf("%s\n",p.name);

    [self test:p.name];

    [self test1:p.age];

    [self test2:&p];

    char ch[5];

    ch[0] = 45;

    

    

    

}

-(void)test:(char*)ch

{

    NSString * ss = [[NSString alloc]initWithCString:ch encoding:NSUTF8StringEncoding];

    NSLog(@"%@",ss);

    

}

-(void)test1:(int)age

{

    NSLog(@"%d",age);

}

-(void)test2:(Person*)pp

{

    NSString * ss = [[NSString alloc]initWithCString:(*pp).name encoding:NSUTF8StringEncoding];

    NSLog(@"%@",ss);

 

}

@end

 

使用结构中的成员变量在oc 中进行数据传递

原文:http://www.cnblogs.com/zkzzkz/p/5149535.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!