博客园  :: 首页  :: 新随笔  :: 订阅 订阅  :: 管理

2012年4月25日

摘要: 1 + (ccColor3B)colorWithHexString: (NSString *) stringToConvert 2 { 3 //去掉前后空格换行符 4 NSString *cString = [[stringToConvert stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString]; 5 6 if ([cString length] < 6) 7 return ccWHITE; 8... 阅读全文

posted @ 2012-04-25 14:57 扬名 阅读(1966) 评论(0) 推荐(1)

摘要: http://www.cocoachina.com/bbs/read.php?tid=31300使用NSStream来实现Socket 阅读全文

posted @ 2012-04-25 14:01 扬名 阅读(539) 评论(0) 推荐(0)

摘要: 转载自:http://tech.it168.com/a2009/1229/830/000000830741.shtml使用网络通信流 使用套接字在网络上通信最简单的方法是使用NSStream类,NSStream类是一个表示流的抽象类,你可以使用它读写数据,它可以用在内存、文件或网络上。使用NSStream类,你可以向服务器写数据,也可以从服务器读取数据。 在Mac OS X上,可以使用NSHost和NSStream对象建立到服务器的连接,如:1 NSInputStream *iStream; 2 NSOutputStream *oStream; 3 ... 阅读全文

posted @ 2012-04-25 13:58 扬名 阅读(1404) 评论(0) 推荐(1)

摘要: 转载自http://unmi.cc/nsnotificationcenter-usage,作者“隔叶黄莺”通常我们在iOS中发生什么事件时该做什么是由Delegate实现的,例如View加载完后会触发viewDidLoad。Apple 还为我们提供了另一种通知响应方式,那就是NSNotification,系统中(UIKeyboardDidShowNotification等) 以及某些第三方组件(例如ASIHTTPRequest的 kReachabilityChangedNotification等)。NSNotificationCenter较之于Delegate可以实现更大的跨度的通信机制,可以 阅读全文

posted @ 2012-04-25 13:45 扬名 阅读(9414) 评论(0) 推荐(0)

摘要: 转载自http://hi.baidu.com/popln/blog/item/e6ed14884b2fa4a60f2444d1.html 在当前的run循环中通过异步查询UIDevice当前的标志和网络状态,对网络连接状态进行监视。当连接状态变化时,观察者(observer)会以回调函数的形式接收到通知,从而做出相应的处理。#import <SystemConfiguration/SystemConfiguration.h>#include <netdb.h>#import <dlfcn.h>#import "UIDevice-Reachabili 阅读全文

posted @ 2012-04-25 13:41 扬名 阅读(3117) 评论(0) 推荐(0)