Objective-c基础
zyx-virus
刚升起的太阳
展开
-
Objective-C 面向对象一
建一个类Student类:文件 定义@interface Student : NSObject{ @public NSString *_name; // @protected NSInteger _age; // @private NSString *_hobby; NSString *_address;原创 2015-12-11 19:43:20 · 381 阅读 · 0 评论 -
Objective-C 单例
/** * Student.h文件 * */#import @interface Student : NSObject//在要设计成单例类的 .h 文件声明一个构造的单例方法+ (Student *)sharedStudent;@end/** * Student.m 文件 */#import "Student.h"//声明一个静态实例对象 只能执行一次stat原创 2016-01-27 19:31:23 · 456 阅读 · 0 评论 -
Objective-C 通知
创建一个老师类 和 学生类 实现通知/** * 老师类 * Teacher.h * */#import @interface Teacher : NSObject//这里设置成单例 以为只有一个老师发通知+ (Teacher *)sharedTeacher;//老师发通知- (void)sendMessage;@end/** * Teacher.m原创 2016-01-27 20:07:15 · 401 阅读 · 0 评论 -
iOS(学习3) UITextField 常用属性
#import “ViewController.h"//设置代理@interface ViewController (){ UITextField *textField; UIButton *_button;}@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoa原创 2016-01-22 22:47:52 · 332 阅读 · 0 评论 -
Objective-C 字典:"NSDictionary" 和 "NSMutableDictionary"
#import int main(int argc, const char * argv[]) { @autoreleasepool { /*-------------------- NSDictionary ---------------------*/ //value在前,key 在后,value 和 key 要成双出现原创 2015-12-20 15:11:28 · 379 阅读 · 0 评论 -
Objective-C 字符串一 "不可变字符串"
#import int main(int argc, const char * argv[]) { @autoreleasepool { // NSString 不可变的字符串 // 1.初始化一个字符串 NSString *string1 = @"ibokanwisdom"; NSLog(@"strin原创 2015-12-15 20:10:23 · 343 阅读 · 0 评论 -
Objective-C 字符串二 "可变字符串"
#import int main(int argc, const char * argv[]) { @autoreleasepool { //可变字符串 NSMutableString NSMutableString *mString1 = [NSMutableString stringWithString:@"nihao"];原创 2015-12-15 20:08:00 · 305 阅读 · 0 评论 -
IOS之同步请求、异步请求、GET请求、POST请求
同步GET请求 //第一步,创建URL NSURL *url = [NSURL URLWithString:@"http://api.hudong.com/iphonexml.do?type=focus-c"]; //第二步,通过URL创建网络请求 NSURLRequest *request = [[NSURLRequest allo转载 2015-12-29 17:21:26 · 260 阅读 · 0 评论 -
objective-C 数组二 "可变数组"
#import int main(int argc, const char * argv[]) { @autoreleasepool { //可变数组 NSMutableArray 它是NSArray的子类 //初始化方法 //初始化一个空间的可变数组 NSMutableArray *mArray1 =原创 2015-12-15 13:20:18 · 395 阅读 · 0 评论 -
Objective-C 数组一 "不可变数组"
#import int main(int argc, const char * argv[]) { @autoreleasepool { //不可变数组 NSArray //初始化 //创建一个空数组 NSArray *array1 = [[NSArray alloc] init];原创 2015-12-14 20:22:47 · 402 阅读 · 0 评论 -
Objective-C 面向对象, 实例方法和类方法
建一个Person类 //定义实例方法和类方法/* OC中的方法 方法:是类的功能代码,在(.h)文件中声明,在(.m)文件中实现。 语法: - | + (返回类型)方法名:参数列表; { // 方法体 } 减号(-)表示实例方法,加号(+)表示类方法 *///类方法/* 注意 1.类方法可以调用类方法 2.类方法不可以调用实例方法,但原创 2015-12-11 20:14:27 · 431 阅读 · 0 评论 -
Objective-C 协议最基本解释
/** * 生活中的协议 * 租户和房东之间的协议 * * 房东的义务:a.交水电费 b.交暖气费 c.交业务费 * 租户的义务:a.交房租 b.保护房内物品 * */#import /** * 协议最基本用法 * @protocol 协议名 * * 在协议中只声明方法,而没有方法实现 */@protocol U原创 2016-01-28 17:07:38 · 304 阅读 · 0 评论