63,匿名对象
2015-12-06 12:05
330 查看
#import <Foundation/Foundation.h>
@interface Iphone :
NSObject
-(void)getBrand;
@end
@implementation Iphone
-(void)getBrand{
NSLog(@"苹果手机");
}
@end
int main(int argc,
const char * argv[]) {
@autoreleasepool {
//1,有名称的对象
Iphone *p = [Iphone
new];
[p getBrand];
//2,匿名对象
//适用场景:只使用一次就使用匿名对象——对象作为一次性参数传入或使用
[[Iphone new]
getBrand];
}
return 0;
}
//2015-12-06 12:03:29.209 6,匿名对象[1041:82129]
苹果手机
//2015-12-06 12:03:29.210 6,匿名对象[1041:82129]
苹果手机
//Program ended with exit code: 0
@interface Iphone :
NSObject
-(void)getBrand;
@end
@implementation Iphone
-(void)getBrand{
NSLog(@"苹果手机");
}
@end
int main(int argc,
const char * argv[]) {
@autoreleasepool {
//1,有名称的对象
Iphone *p = [Iphone
new];
[p getBrand];
//2,匿名对象
//适用场景:只使用一次就使用匿名对象——对象作为一次性参数传入或使用
[[Iphone new]
getBrand];
}
return 0;
}
//2015-12-06 12:03:29.209 6,匿名对象[1041:82129]
苹果手机
//2015-12-06 12:03:29.210 6,匿名对象[1041:82129]
苹果手机
//Program ended with exit code: 0
相关文章推荐
- 探索PHP7(一)--性能
- 编写猜数字小游戏
- 【linux】网络编程基础(c语言编程)
- Scala单例对象、伴生类以及伴生对象、apply介绍
- phalapi-进阶篇5(数据库读写分离以及多库使用)
- LeetCode 005 Longest Palindromic Substring
- printf sprintf fprintf
- 在Linux上使用Wine安装轻聊版的QQ的步骤讲解
- 黑马程序员——OC基础之NSString类
- LeetCode 列表合并问题
- phalapi-进阶篇3(自动加载和拦截器)
- phalapi-进阶篇4(notrom进阶以及事务操作)
- C++链接MySQL数据库实例应用
- cdoj 1256 昊昊爱运动 预处理/前缀和
- python psutil 终止子进程
- 黑马程序员——OC基础之点语法
- HDU 5273 Dylans loves sequence 区间DP
- cdoj 1255 斓少摘苹果 贪心
- jforum MVC中的控制器
- 【Html】使用mailto在网页中链接Email地址