摘要: Reachability.h文件在iOS6中会出现这样的一个Warning:SemanticDeclaration of 'struct sockaddr_in' will not be visible outside of this function.解决方法是引入以下的Header文件:#import <netinet/in.h> 阅读全文
posted @ 2013-04-08 09:36 BankFish 阅读(890) 评论(0) 推荐(0) 编辑
摘要: 1. 关于iPhone系统电话事件监听#import <CoreTelephony/CTCallCenter.h>#import <CoreTelephony/CTCall.h>- (void)listenCallEvent{ CTCallCenter *callCenter = [[CTCallCenter alloc] init]; [callCenter setCallEventHandler:^(CTCall *call) { if (call.callState == CTCallStateConnected) { NSL... 阅读全文
posted @ 2013-03-31 21:17 BankFish 阅读(980) 评论(0) 推荐(0) 编辑
摘要: 1. 在UIModalPresentationFormSheet(iPad device, without a UINavigationController)下的视图中,如果使用[inputView resignFirstResponder];是不能把Keyboard收起的,需要使用以下的方式:A: @try { Class UIKeyboardImpl = NSClassFromString(@"UIKeyboardImpl"); id activeInstance = [UIKeyboardImpl performSelector:@selector(activeIns 阅读全文
posted @ 2013-03-30 22:16 BankFish 阅读(1728) 评论(0) 推荐(0) 编辑
摘要: 一般App在设备上启动后都会有做版本检测以确认本版本是否是最新版本的App,以便提示用户更新到最新版本。当然可以在公司的的服务器做接口查询,这是一个比较笨的办法,但鉴于iOS App的上架App特性,我们希望检测到当前设备安装的版本与App Store上的版本比较,具体操作如下:1. 如何从App Store上获取指定App的信息? 这里可以通过Apple公司提供的REST接口进行查询,其接口如下: http://itunes.apple.com/lookup?id=appid 参数appid指的是你在app在创建后的唯一标识,在iTunes Connect里可以查找到此信息。 ... 阅读全文
posted @ 2013-03-20 21:58 BankFish 阅读(7040) 评论(6) 推荐(0) 编辑
摘要: Chapter 12 : 归档1. 归档 :-> 定义: 用某种格式来保存一个或多个对象,以便以后还原这些对象的过程。其中包括将多个对象写入文件,以便以后读回该对象。-> 方法:(1)属性列表; (2)带键值的编码。2. 属性列表:若对象是NSString, NSDictionary, NSArray, NSData, NSNumber对象时,可以使用writeToFile:atomically:方法将数据写入到文件中,是以属性列表的形式写到文件中的。PS : 参数atomically为YES, 表示先将数据写到临时备份文件中,一旦成功,再转移到文件中。示例代码:#import & 阅读全文
posted @ 2012-09-28 17:48 BankFish 阅读(493) 评论(0) 推荐(0) 编辑
摘要: Chapter 11 : 复制对象1. 回顾继承部分的代码如下: 1 // XYPoint类声明 2 // XYPoint.h文件 3 4 #import <Foundation/Foundation.h> 5 6 @interface XYPoint : NSObject 7 { 8 int x; 9 int y;10 }11 12 @property int x;13 @property int y;14 15 - (void)setX:(int)xVal andY:(int)yVal;16 17 @end 1 // XYPoint类定义 2 // XYPoint.m文... 阅读全文
posted @ 2012-09-28 16:45 BankFish 阅读(555) 评论(0) 推荐(0) 编辑
摘要: Chapter 10 : 属性列表PS : Objective-C可使用与C绑定的所有工具,例如标准C库函数。可使用malloc()和free()函数处理动态内存管理问题,或者使用open(), read(), write(), fopen()和fread函数处理文件。-> 属性列表类包括NSArray, NSDictionary, NSString, NSNumber, NSDate和NSData。1. NSDate :用于处理日期和时间的基础类,是一个自动释放对象。示例如下:1 // 获取当前日期和时间2 NSDate *date = [NSDate date];3 NSLog(@& 阅读全文
posted @ 2012-09-28 15:34 BankFish 阅读(465) 评论(0) 推荐(0) 编辑
摘要: Chapter 9 : 分类和协议1. 协议(protocol) : 其声明类于类接口的声明,不同的是,协议没有父类,且不能定义成员变量。2. 协议(protocol)声明如下:1 @protocol MyProtocol2 3 - (void)myProtocolMethod;4 5 @end-> 协议(protocol)是多个类共享的一个方法列表(Methods List), 协议(protocol)中列出的方法没有相应的实现。如果一个类采用MyProtocol协议,则必须实现名为myProtocolMethod的方法。3. 协议(protocol)的使用: 通过在@interfa. 阅读全文
posted @ 2012-09-28 12:02 BankFish 阅读(266) 评论(0) 推荐(0) 编辑
摘要: Chapter 9 : 分类和协议1. 分类(Category):-> 作用:可以以模块的方式向现有的类添加方法,将类的定义模块化到相关方法的组或分类中。-> 意义:提供了扩展现有类定义的简便方式,并且不必访问类的源代码,也无需创建子类。2. 示例代码: 1 // Fraction类声明 2 // Fraction.h文件 3 4 #import <Foundation/Foundation.h> 5 6 @interface Fraction : NSObject 7 { 8 int numerator; 9 int denominator;10 }11 12 @pr 阅读全文
posted @ 2012-09-28 11:35 BankFish 阅读(204) 评论(0) 推荐(0) 编辑
摘要: Chapter 8 :动态绑定和id类型1. 示例代码: 1 // 用到的类请参照前面的笔记 2 3 // 两个类中都含有print方法 4 #import "Fraction.h" 5 #import "Complex.h" 6 7 int main(int argc, const char *argv[]) 8 { 9 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];10 11 Fraction *f = [[Fraction alloc] init];12 Complex *c 阅读全文
posted @ 2012-09-28 11:06 BankFish 阅读(127) 评论(0) 推荐(0) 编辑