我写了许多与后端通信的iOS应用程序.几乎每次,我都使用HTTP缓存来缓存查询并将响应数据(JSON)解析为Objective-C对象.对于这个新项目,我想知道核心数据方法是否有意义.
这就是我的想法:
iOS客户端向服务器发出请求,并将对象从JSON解析为CoreData模型.
每当我需要一个新对象,而不是直接获取服务器时,我解析CoreData以查看我是否已经发出了该请求.如果该对象存在且尚未过期,则使用获取的对象.
但是,如果对象不存在或已过期(这里将应用某些缓存逻辑),我将从服务器获取对象并相应地更新CoreData.
我认为拥有这样的架构可以帮助实现以下目标:1.避免对后端进行不必要的查询2.允许完全支持离线浏览(您仍然可以使用DataCore的RDBMS进行关系查询)
现在这是我对神的问题:
尝试使用convert(1)时,我收到以下错误:
dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries/libclparser.dylib
Referenced from: /usr/local/bin/convert
Reason: image not found
Trace/BPT trap: 5
Run Code Online (Sandbox Code Playgroud)
知道如何解决它吗?
我有一个有很多注释的mapview,其中大多数都非常接近.我想要做的是类似于iOS上的Photo应用程序,当它们彼此太靠近时,注释被分组,每当你缩小时,如果注释距离太远,它们就会被分组.
我已经看过这个问题,但给出的答案并不是我真正想要的.
我正在寻找可以自己实现的库或算法.
我一直在使用这种方法,但从未真正了解它们的行为方式.
每当我尝试使用它们时,我发现自己在黑暗中探索,因为我尝试了不同的方面,它似乎永远不会按照我的期望去做.
为了争论,我试图转换我从UIKeyboard的通知中得到的帧.
在横向模式下,我得到了这个NSRect:
UIKeyboardFrameEndUserInfoKey = NSRect: {{406, 0}, {362, 1024}}
Run Code Online (Sandbox Code Playgroud)
现在我想将它转换为正确的矩形(交换x/y,宽度和高度),所以我这样做
CGRect compatibleRect = [self convertRect:[[[notif userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue] toView:nil];
Run Code Online (Sandbox Code Playgroud)
但是矩形成为:
compatibleRect = CGRect: {{406,406}, {362, 1024}}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激 :)
我想出了AVFoundation和ImageIO的实现来处理我的应用程序中的照片.不过,我有一个问题.即使闪光灯熄灭,我拍摄的图像也总是很暗.这是我使用的代码:
[[self currentCaptureOutput] captureStillImageAsynchronouslyFromConnection:[[self currentCaptureOutput].connections lastObject]
completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
[[[blockSelf currentPreviewLayer] session] stopRunning];
if (!error) {
NSData *data = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef) data, NULL);
if (source) {
UIImage *image = [blockSelf imageWithSource:source];
[blockSelf updateWithCapturedImage:image];
CFRelease(source);
}
}
}];
Run Code Online (Sandbox Code Playgroud)
有没有什么可以导致图像不包括闪光灯?
是否可以通过此动态查询创建更清晰的东西:
@photos = Photo.within(100, :origin => [params[:latitude], params[:longitude]]) unless (params[:latitude].nil? || params[:longitude].nil?)
if @photos.nil? then
conditions = String.new
values = Array.new
params.each_key do |key|
if key == 'since_id' then
conditions << " AND " unless conditions.length == 0
conditions << "id > ?"
values << params[key]
elsif key == 'user_id' then
conditions << " AND " unless conditions.length == 0
conditions << "user_id = ?"
values << params[key]
elsif key == 'id' then
conditions << " AND " unless conditions.length …Run Code Online (Sandbox Code Playgroud) 我今晚正在做一些测试来看看当地人的行为UINavigationBar.我创建了一个简单的代码片段,它执行以下操作:
- (void)pushController {
PHViewController *ctrl2 = [[[PHViewController alloc] initWithNibName:@"PHViewController" bundle:nil] autorelease];
ctrl2.shouldShowPrompt = YES;
[self.viewController pushViewController:ctrl2 animated:YES];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
PHViewController *ctrl = [[[PHViewController alloc] initWithNibName:@"PHViewController" bundle:nil] autorelease];
ctrl.shouldShowPrompt = YES;
ctrl.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Push"
style:UIBarButtonItemStyleDone
target:self
action:@selector(pushController)] autorelease];
self.viewController = [[[PHNavigationController alloc] initWithRootViewController:ctrl] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
现在我已经将UINavigationBar其分类 …
ios ×4
activerecord ×1
architecture ×1
avfoundation ×1
cocoa-touch ×1
core-data ×1
imagemagick ×1
ios4 ×1
ipad ×1
iphone ×1
macos ×1
mapkit ×1
mkannotation ×1
objective-c ×1
osx-lion ×1
uikit ×1
xcode ×1
xcode4 ×1