删除核心数据对象时如何处理外部数据的清理

我对Core Data相当陌生,遇到了别人必须遇到的问题。 我的数据模型包括图像,我保留那些外部的数据库,并简单地存储path/ URL到图像。 (根据苹果核心数据演示文稿中的build议) 当删除我的图像对象,我可以手动遍历关系,并删除图像文件,但我想知道是否有一个更优雅的方式来做到这一点。 理想的解决scheme将以某种方式与图像对象绑定,并且可以与Core Data撤消/重做一起使用。

NSURLSession委托和completionHandler

我正在使用NSURLSession + NSURLDownloadTask with completionHandler: [session downloadTaskWithURL:downloadURL completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) 它工作很好。 但是当我想跟踪进度栏中的下载时,我遇到了问题。 我正在尝试使用NSURLSessionDownloadDelegate来跟踪加载。 与上面的完成处理程序,它永远不会被称为? 使用: NSURLSessionDownloadTask *downloadTask = [session downloadTaskWithURL:downloadURL]; 会打电话给代表。 有没有办法使用completionHandler和委托? 或者使用completionHandler跟踪下载的任何其他方式?

如何从没有filter的设备中检索所有CNContactStore

我试图插入到var contacts: [CNContact] = [] var store = CNContactStore()但我没有find这个工作的正确的代码,我发现这个函数,我需要给这个名字 func findContactsWithName(name: String) { AppDelegate.sharedDelegate().checkAccessStatus({ (accessGranted) -> Void in if accessGranted { dispatch_async(dispatch_get_main_queue(), { () -> Void in do { let predicate: NSPredicate = CNContact.predicateForContactsMatchingName(name) let keysToFetch = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactBirthdayKey, CNContactViewController.descriptorForRequiredKeys()] self.contacts = try self.store.unifiedContactsMatchingPredicate(predicate, keysToFetch:keysToFetch) self.tableView.reloadData() } catch { print("Unable to refetch the selected […]

iPhone 4 AVFoundation:同时捕捉前后相机

我想知道是否有可能使用AVFoundation框架同时捕获两个摄像头。 具体来说,我的问题是前后AVCaptureDevices是否可以同时活动。 目前我知道一个AVCaptureSession实例只能支持一个input(和输出)。 我创build了两个AVCaptureSessions,将前置摄像头设备连接到另一个,然后将会话的输出指向不同的SampleBufferDelegate函数。 我所看到的是一个委托function是活动几帧,然后另一个接pipe。 看起来好像AVFoundation以某种方式closures相机设备,如果另一个正在使用。 任何人都可以证实这一点,或分享他们在这个问题上的经 提前致谢

AVPlayer不显示任何东西

我尝试从youtube vimeo,dailymotion中embedded不同的video。 可悲的是在这一刻没有任何东西显示,除了我的containerView的backgroundcolor: UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0, 320.0f, 200.0f)]; //item.url is my url which i get fro my webserver, it looks like http://www.youtube.com/watch?v=zPP6lXaL7KA&feature=youtube_gdata_player AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:item.url]]; AVPlayer *avPlayer = [AVPlayer playerWithPlayerItem:playerItem]; NSLog(@"%@",playerItem); AVPlayerLayer *avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer]; avPlayerLayer.frame = self.frame; [containerView.layer addSublayer:avPlayerLayer]; [self addSubview:containerView]; [avPlayer play]; if (avPlayer.status == […]

iOS刷新mapview上的注释

我有一个mapview,其注释的坐标不断更新,但是当我使用setCoordinate时,注释不会移动。 如何刷新注释以反映其坐标? – (void)updateUnits { PFQuery *query = [PFQuery queryWithClassName:@"devices"]; [query whereKeyExists:@"location"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { for (PFObject *row in objects) { PFGeoPoint *geoPoint = [row objectForKey:@"location"]; CLLocationCoordinate2D coord = { geoPoint.latitude, geoPoint.longitude }; for (id<MKAnnotation> ann in mapView.annotations) { if ([ann.title isEqualToString:[row objectForKey:@"deviceid"]]) { [ann setCoordinate:coord]; NSLog(@"latitude is: %f" […]

检测何时按下“回到应用程序”

我已经创build了一个函数,这个函数是用来处理位置权限的,所以如果它没有位置权限的话就会closures。 但是,当您按下打开的设置,然后按状态栏中的“回到应用程序”,则不会再次执行determeinePermission方法。 我试图将其添加到viewDidLoad , viewDidAppear和viewWillAppear 。 我能做什么? func determinePermission() { switch CLLocationManager.authorizationStatus() { case .Authorized: if CLLocationManager.locationServicesEnabled() { manager.delegate = self manager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters manager.startUpdatingLocation() } case .NotDetermined: manager.requestWhenInUseAuthorization() case .AuthorizedWhenInUse, .Restricted, .Denied: let alertController = UIAlertController( title: "Background Location Access Disabled", message: "In order to be notified about adorable kittens near you, please open […]

ARKit无法运行会话,此设备不支持configuration

在iPhone 6上使用ARWorldTrackingSessionConfiguration获取和错误外加Unable to run the session, configuration is not supported on this device 它可能是什么?

如何使UINavigationBar在IOS 8中透明?

我已经尝试了很多,使UINavigationBar透明。 但是我没有做到这一点。我设定的形象是透明的。 这是我的代码。 任何帮助? 提前致谢。 [rootNavC.navigationBar setBackgroundImage:[UIImage imageNamed:@"NAV_BG_iphone.png"] forBarMetrics:UIBarMetricsDefault]; rootNavC.navigationBar.translucent = YES; rootNavC.navigationBar.backgroundColor = [UIColor clearColor]; [[UINavigationBar appearance] setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor whiteColor], UITextAttributeTextShadowColor : [UIColor clearColor], UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeFont : [UIFont fontWithName:@"pastel" size:20] }];

SKNode位置不工作,总是默认为0,0

我已经开发了相当不错的SpriteKit游戏,添加了一些代码来添加一个新的SKSpriteNode到场景中(和我在代码中做了几十个其他地方一样,但是由于某种原因,这次只是忽略了位置我已经设置了节点,我已经尝试了显式.position = CGPointMake(x,y)并尝试[node setPosition:CGPointMake(x,y)] 既没有工作,节点也没有添加到场景中,但总是在0,0,无论我做了什么,都检查了x和y,以确保它们是有效的,并在场景的范围内,并尝试使用显式的浮点数等,不pipe我做什么,这个节点总是显示在0,0,这是毫无意义的。 我正在做的和我在其他几十个节点上玩游戏的过程一样,但是这个节点不会出现在任何地方,除了0,0,无论我做什么: int width = 64; SKSpriteNode *node = [[SKSpriteNode alloc] initWithColor:[SKColor grayColor] size:CGSizeMake(width,25)]; node.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:node.size]; node.physicsBody.dynamic = NO; node.physicsBody.categoryBitMask=nodeCategory; node.name=@"node"; node.position = CGPointMake(200,250); //Have also tried [node setPosition:CGPointMake(200,250); [self addChild:node]; 我在这里完全不知所措,我已经尝试在CGPointMake的input中join.0,以确保它们被作为浮点数处理。无论我如何处理这个节点,当它被添加到场景时,它总是默认为0,0的位置,我感到沮丧,我正在添加各种各样的节点没有事件,只是关于这个节点添加,这只是不工作,不知道什么是不同的或为什么。