objective-c之struct
来源:互联网 发布:培罗成西服淘宝店 编辑:程序博客网 时间:2024/06/05 17:18
//// main.m// struct//// Created by wu jianhua on 16-8-3.// Copyright (c) 2016年 wujianhua. All rights reserved.//#import <Foundation/Foundation.h>struct Books{ NSString *title; NSString *author; NSString *subject; int book_id;};@interface SampleClass : NSObject- (void) printBook:(struct Books) book;- (void) printBook2:(struct Books*)book;@end@implementation SampleClass- (void)printBook:(struct Books)book{ NSLog(@"Book title : %@", book.title); NSLog(@"Book author : %@", book.author); NSLog(@"Book subject : %@ ", book.subject); NSLog(@"Book book_id : %d ", book.book_id); }- (void)printBook2:(struct Books *)book{ NSLog(@"Book title : %@", book->title); NSLog(@"Book author : %@", book->author); NSLog(@"Book subject : %@ ", book->subject); NSLog(@"Book book_id : %d", book->book_id); }@endvoid test001(){ struct Books Book1; /* Declare Book1 of type Book */ struct Books Book2; /* Declare Book2 of type Book */ /* book 1 specification */ Book1.title = @"Objective-C Programming"; Book1.author = @"Nuha Ali"; Book1.subject = @"Objective-C Programming Tutorial"; Book1.book_id = 6495407; /* book 2 specification */ Book2.title = @"Telecom Billing"; Book2.author = @"Zara Ali"; Book2.subject = @"Telecom Billing Tutorial"; Book2.book_id = 6495700; /* print Book1 info */ NSLog(@"Book 1 title : %@", Book1.title); NSLog(@"Book 1 author : %@", Book1.author); NSLog(@"Book 1 subject : %@", Book1.subject); NSLog(@"Book 1 book_id : %d", Book1.book_id); /* print Book2 info */ NSLog(@"Book 2 title : %@", Book2.title); NSLog(@"Book 2 author : %@", Book2.author); NSLog(@"Book 2 subject : %@ ", Book2.subject); NSLog(@"Book 2 book_id : %d ", Book2.book_id); }void test002(){ struct Books Book1; /* Declare Book1 of type Book */ struct Books Book2; /* Declare Book2 of type Book */ /* book 1 specification */ Book1.title = @"Objective-C Programming"; Book1.author = @"Nuha Ali"; Book1.subject = @"Objective-C Programming Tutorial"; Book1.book_id = 6495407; /* book 2 specification */ Book2.title = @"Telecom Billing"; Book2.author = @"Zara Ali"; Book2.subject = @"Telecom Billing Tutorial"; Book2.book_id = 6495700; SampleClass *sc=[[SampleClass alloc] init]; [sc printBook:Book1]; [sc printBook:Book2]; }void test003(){ struct Books Book1; /* Declare Book1 of type Book */ struct Books Book2; /* Declare Book2 of type Book */ /* book 1 specification */ Book1.title = @"fuck Objective-C Programming"; Book1.author = @"Nuha Ali"; Book1.subject = @"Objective-C Programming Tutorial"; Book1.book_id = 6495407; /* book 2 specification */ Book2.title = @"Telecom Billing"; Book2.author = @"Zara Ali"; Book2.subject = @"Telecom Billing Tutorial"; Book2.book_id = 6495702; SampleClass *sc=[[SampleClass alloc] init]; [sc printBook2:&Book1]; [sc printBook2:&Book2]; }int main(int argc, const char * argv[]){ test001(); test002(); test003(); return 0;};
0 0
- objective-c之struct
- Objective-C之Foundation中常见的结构体struct
- Objective-C学习笔记-之结构体struct
- Objective-C--- NSValue 详解 struct 结构体
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- ARC forbids Objective-C objects in struct
- c语言之struct
- c语言之结构(struct)
- Objective-C 之NSAutoreleasePool
- objective-c 之 static
- objective-c之NSString
- Objective-c之NSCopying
- react-native android教程一(AS中使用react-native)
- 优先队列 POJ 2010
- href和src有什么区别
- code_snippet 自定义代码块
- 基于微服务的软件架构模式
- objective-c之struct
- 第一天开启CSDN博客之旅
- poj3020 Antenna Placement
- LIS和LCS
- 文章标题
- 2016多校第五场 1001 HDU 5781 DP
- 堆的实现andprioity-queue函数
- 弹性盒子flex布局实现骰子六个面并让骰子3D空间旋转
- 剑指offer 约瑟夫环问题