面试题4
来源:互联网 发布:西南大学网络教育如何 编辑:程序博客网 时间:2024/06/06 02:55
58. 线程之间怎么通信?
59. 线程生产者,消费者如何实现?
1 个线程是生产者,一个是消费者如何实现这个模型.
NSMutableArray *dataList;NSLock *dataLock;
- (void) produceAndConsume {
dataList = [[NSMutableArray alloc] init];
dataLock = [[NSLock alloc] init];
[NSThread detachNewThreadSelector:@selector(produce:) toTarget:self withObject:nil];[NSThread detachNewThreadSelector:@selector(consume:) toTarget:self withObject:nil];
}
- (void) produce:(id)arg {
int index = 0;while (1) {
NSNumber *n = [NSNumber numberWithInt:index++];[dataLock lock];
[dataList addObject:n];
[NSThread sleepForTimeInterval:0.5];
}}
- (void) consume:(id)arg {while (1) {
if ([dataList count] > 0) {[dataLock lock];
id obj = [dataList objectAtIndex:0];[dataList removeObject:0];[dataLock unlock];
NSLog(@"消费 obj %@", obj);
}
[NSThread sleepForTimeInterval:1];}
}
60.不同屏幕怎么适配
iphone, iphone3G, iphone3GS 320x480
iphone4, iphoen4S 640x960 retina
iphone5, iphone5S, 640x1136
写程序需要有 2套图片 demo.png demo@2x.pngiphone5适配.
1136/2-44-49
[[UIScreenmainScreen]applicationFrame] = (320x460, 320x548)[[UIScreenmainScreen]bounds] = (320x480, 320x568)
iPad, iPad2, iPad Mini 1024x768
iPad3, iPad4, 2048x1563
61. 不同版本屏幕旋转怎么适配62.内存警告应该怎么做
尽量多的释放内存。把一些内容写到文件中,不要保存在内存中。63. iOS5, iOS6, iOS7区别
64. NSNotification是同步还是异步的
是同步的.如果需要异步 必须使用 NSNotificationQueue 实现
A notification center delivers notifications to observers synchronously. In other words, thepostNotification: methods do not return until all observers have received and processed thenotification. To send notifications asynchronously use NSNotificationQueue.
In a multithreaded application, notifications are always delivered in the thread in which thenotification was posted, which may not be the same thread in which an observer registereditself.
Hope it helps you.
- 英文面试题(4)
- Java面试题(4)
- C++面试题4
- C++面试题4
- .net面试题4
- 面试题4
- 面试题4
- 面试题(4)
- .net面试题4
- .NET面试题 - 4
- 面试题4
- 面试题4
- 面试题4
- hibernate面试题4
- 面试题4
- 网络面试题4
- 面试题4
- 面试题4
- Windows 右键相关:不用按Shift,直接显示“在此处打开命令窗口 ”
- 求int型数据在内存中存储时1的个数
- Unity shader学习资料
- Spring和MyBatis学习 (卷首)
- hdu2222(AC自动机入门)
- 面试题4
- Failed to load class "org.slf4j.impl.StaticLoggerBinder问题故障的解决
- 基金公司官方网站设计建设
- Xcode清除多余的Provisioning Profile
- 黑马程序员——Set实现类、Collections工具类
- scala-04For与Function进阶实战、Lazy的使用
- Codeforces Round #315-Codeforces Round #315(贝尔数)
- 设置DIV为不可见
- hdu 1671 Phone List(字典树·粉刷式标记)