码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-01-21 23:23:08      阅读:132      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!