· iOS中NSOperationQueue与GCD分派队列 我们已经知道iOS还提供了一种叫做NSOperationQueue的队列机制。就像分派队列一样,它也接受块作为参数并加入队列。你可能会问
一个UI事件,Timer call, delegate call, 都会是一个新的Runloop iOS有没有垃圾回收? Objective-C 2.0也是有垃圾回收机制的,但是只能在Mac OS X Leopard
#import "ViewController.h" @interface ViewController () @property(nonatomic,strong)UITextView *textView; @property(nonatomic,copy)NSString *BASE_URL; @property(nonatomic,copy)NSString *BASE_URL1_PARAM
简单的音乐播放 导入AVFoundation.framework - (void)viewDidLoad { [super viewDidLoad]; //路径 NSString* path = [[NSBundle mainBundle] pathForResource:@"xiguan" ofType:@"mp3"]; //路径->url NSURL* url = [NSURL fileURL
网络监听用到的类为Reachability.h,这个Xcode项目里面是不自带的,需要从github上面下载,在使用的时候记着导入SystemConfiguration.framework。 首先是在AppDelegate.m中设置网络监听 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reach
首先要先导入第三方类库FMdatabase。 获得存放数据库文件的沙盒地址。 +(NSString*)databaseFilePath [objc] view plaincopy { NSArray*filePath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString*doc
IOS中对JSON格式的解析通常可以采用NSJSONSerialization来实现. 如,我们可以用个简答的HTTP请求的方式获取JSON数据,(以下都是在playground中写的) var
处理图片颜色 - (UIImage*)grayscale:(UIImage*)anImage type:(int)type{ CGImageRef imageRef = anImage.CGImage; size_t width = CGImageGetWidth(imageRef); size_t height = CGImageGetHeight(imageRef); size_t bitsP
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. UIImageView *imageView = [[UIImageView alloc] init]; imageView.frame = CGRectMake(0, 0, 80, 120); imageVie
NSDateComponents *_comps = [[NSDateComponents alloc] init]; [_comps setDay:23]; [_comps setMonth:3]; [_comps setYear:2014]; NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGre
1.保存在user Document文件夹下,以读取文件,写入文件方式 2.在工程里手动创建一个.plist文件,把固定的内容写入,这个需要人工手动写入(工程里只可读取,不可以写入) 3.保存在user Document下,不过不需要读写文件,用系统的 NSUserDefaults 可以快速保存添加读取删除基本数据类型 这里记录的是第1种,第2种就是创建一个plist文件,然后自己手动写入数据,再
iOS下的具体实现方式如下 新建一个类 继承 #import
// // ViewController.m // LocationDemo // // Created by LaughingZhong on 14/11/12. // Copyright (c) 2014年 Laughing. All rights reserved. // #import "ViewController.h" @interface ViewController () @end
CLGeocoder *myGeocoder = [[CLGeocoder alloc] init]; [myGeocoder geocodeAddressString:_searchBar.text completionHandler:^(NSArray *placemarks, NSError *error) { if ([placemarks count] > 0 && error == n
[CTSIMSupportGetSIMStatus() isEqualToString:kCTSIMSupportSIMStatusNotInserted] 可以判断是否插入了sim卡。 需要CoreTelephony.framework。 /** * 检测是否有SIM卡 * [CTSIMSupportGetSIMStatus() isEqualToString:kCTSIMSupportSIMS
@interface UIButton (AsyncImage) //size by point - (void)setImageFromURL:(NSString *)urlString adjustToSize:(CGSize)size completion:(void (^)(void))completion logo:(UIImage *)logoImage; @end @implemen
+ (UIImage *) imageFromView: (UIView *) theView { // Draw a view’s contents into an image context UIGraphicsBeginImageContext(theView.frame.size); CGContextRef context = UIGraphicsGetCurrentContext();
GET和POST请求是HTTP请求方式中最最为常见的。在说请求方式之前先熟悉 HTTP 的通信过程: 请求 1 、 请求行 : 请求方法、请求路径、 HTTP 协议的版本 GET /MJServer/resources/images/ 1. jpg HTTP/ 1.1 2、请求头 : 客户端的一些描述信息 Host : 192.168.1.111:8080 // 客户端想访问的服务器主机地址 Us
Flash。 与此同时,Chrome for iOS 也升级到了新版, 继桌面版、Android 版之后,Chrome 26 for iOS 也正式发布了 ,iPad 和 iPhone 用户现在都可以更新至
常常将自己的产品称为艺术与科技的完美结合,至少在乔布斯时代是这样的说的。那么,艺术性对于 Apple 产品是一个重要的评判指标,首先 iOS7 在艺术上就是失败的。 为什么这样说呢?先讲一个故事: 加拿大有一座城市举行了一个艺术大