- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
你得对我放轻松,因为我还在学习,但我有一次弹出这个线程错误,我点击了“登录 Facebook”按钮。这个项目是针对“Tinder”或“Hot or Not”的克隆,我仍处于起步阶段。如果有人可以解释我的错误,我将不胜感激......
2014-02-10 14:27:37.629 MatchedUp[38775:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Found a circular dependency when saving.'
*** First throw call stack:
(
0 CoreFoundation 0x028115e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x025948b6 objc_exception_throw + 44
2 CoreFoundation 0x028113bb +[NSException raise:format:] + 139
3 MatchedUp 0x00006417 +[PFObject(Private) collectDirtyChildren:children:files:seen:seenNew:] + 1174
4 MatchedUp 0x00006200 +[PFObject(Private) collectDirtyChildren:children:files:seen:seenNew:] + 639
5 MatchedUp 0x000064c5 +[PFObject(Private) collectDirtyChildren:children:files:seen:seenNew:] + 1348
6 MatchedUp 0x00006200 +[PFObject(Private) collectDirtyChildren:children:files:seen:seenNew:] + 639
7 MatchedUp 0x000065b5 +[PFObject(Private) collectDirtyChildren:children:files:] + 118
8 MatchedUp 0x00007385 +[PFObject(Private) deepSaveAsync:withSessionToken:] + 204
9 MatchedUp 0x0000890d -[PFObject(Private) saveChildrenAsync:] + 79
10 MatchedUp 0x0000ba48 -[PFObject(Private) saveAsync:] + 151
11 MatchedUp 0x0000b94d __30-[PFObject(Private) saveAsync]_block_invoke + 43
12 MatchedUp 0x0007d0c0 -[PFTaskQueue enqueue:] + 193
13 MatchedUp 0x0000b91b -[PFObject(Private) saveAsync] + 104
14 MatchedUp 0x0000dbf3 -[PFObject saveInBackgroundWithBlock:] + 34
15 MatchedUp 0x00004741 __45-[AGLoginViewController uploadPFFileToParse:]_block_invoke + 321
16 MatchedUp 0x0007c7b4 __53-[PFTask thenCallBackOnMainThreadWithBoolValueAsync:]_block_invoke + 98
17 MatchedUp 0x0007c537 __40-[PFTask thenCallBackOnMainThreadAsync:]_block_invoke_2 + 241
18 libdispatch.dylib 0x02dd57f8 _dispatch_call_block_and_release + 15
19 libdispatch.dylib 0x02dea4b0 _dispatch_client_callout + 14
20 libdispatch.dylib 0x02dd875e _dispatch_main_queue_callback_4CF + 340
21 CoreFoundation 0x02876a5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
22 CoreFoundation 0x027b76bb __CFRunLoopRun + 1963
23 CoreFoundation 0x027b6ac3 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x027b68db CFRunLoopRunInMode + 123
25 GraphicsServices 0x038889e2 GSEventRunModal + 192
26 GraphicsServices 0x03888809 GSEventRun + 104
27 UIKit 0x01302d3b UIApplicationMain + 1225
28 MatchedUp 0x000051ad main + 141
29 libdyld.dylib 0x0307c70d start + 1
30 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
这是我的代码:
//
// AGLoginViewController.m
// MatchedUp
//
// Created by AG on 1/30/14.
// Copyright (c) 2014 Alex Gartenberg. All rights reserved.
//
#import "AGLoginViewController.h"
@interface AGLoginViewController ()
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
@property (strong, nonatomic) NSMutableData *imageData;
@end
@implementation AGLoginViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.activityIndicator.hidden = YES;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark
- (IBAction)loginButtonPressed:(UIButton *)sender
{
self.activityIndicator.hidden = NO;
[self.activityIndicator startAnimating];
NSArray *permissionsArray = @[@"user_about_me", @"user_interests", @"user_relationships", @"user_birthday", @"user_location", @"user_relationship_details"];
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
[self.activityIndicator stopAnimating];
self.activityIndicator.hidden = YES;
if (!user) {
if (!error) {
UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"Login Error" message:@"Facebook Login was not successful" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alertview show];
}
else {
UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"Login Error" message:[error description] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alertview show];
}
}
else{
[self updateUserInformation];
[self performSegueWithIdentifier:@"loginToTabBarSegue" sender:self];
}
}];
}
#pragma mark - Helper Method
-(void)updateUserInformation
{
FBRequest *request = [FBRequest requestForMe];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSDictionary *userDictionary = (NSDictionary *)result;
//create URL
NSString *facebookID = userDictionary[@"id"];
NSURL *pictureURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large&return_ssl_resources=1", facebookID]];
NSMutableDictionary *userProfile = [[NSMutableDictionary alloc] initWithCapacity:8];
if (userDictionary[@"name"]){
userProfile[kCCUserProfileNameKey] = userDictionary[@"name"];
}
if (userDictionary[@"first_name"]){
userProfile[kCCUserProfileFirstNameKey] = userDictionary[@"first_name"];
}
if (userDictionary[@"location"][@"name"]){
userProfile[kCCUserProfileLocationKey] = userDictionary[@"location"][@"name"];
}
if (userDictionary[@"gender"]){
userProfile[kCCUserProfileGenderKey] = userDictionary[@"gender"];
}
if (userDictionary[@"birthday"]){
userProfile[kCCUserProfileBirthdayKey] = userDictionary[@"birthday"];
}
if (userDictionary[@"interested_in"]){
userProfile[kCCUserProfileInterestedInKey] = userDictionary[@"interested_in"];
}
if ([pictureURL absoluteString]) {
userProfile[kCCUserProfilePictureURL] = [pictureURL absoluteString];
}
[[PFUser currentUser] setObject:userProfile forKey:@"profile"];
[[PFUser currentUser] saveInBackground];
[self requestImage];
}
else {
NSLog(@"Error in Facebook Request %@", error);
}
}];
}
-(void)uploadPFFileToParse:(UIImage *)image
{
NSData *imageData = UIImageJPEGRepresentation(image, 0.8);
if (!imageData) {
NSLog(@"image data was not found");
return;
}
PFFile *photoFile = [PFFile fileWithData:imageData];
[photoFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
PFObject *photo = [PFObject objectWithClassName:kCCPhotoClassKey];
[photo setObject:[PFUser currentUser] forKey:kCCPhotoUserKey];
[photo setObject:photo forKey:kCCPhotoPictureKey];
[photo saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
NSLog(@"Photo Saved Successfully");
}];
}
}];
}
-(void)requestImage
{
PFQuery *query = [PFQuery queryWithClassName:kCCPhotoClassKey];
[query whereKey:kCCPhotoUserKey equalTo:[PFUser currentUser]];
[query countObjectsInBackgroundWithBlock:^(int number, NSError *error) {
if (number ==0)
{
PFUser *user = [PFUser currentUser];
self.imageData = [[NSMutableData alloc] init];
NSURL *profilePictureURL = [NSURL URLWithString:user[kCCUserProfileKey][kCCUserProfilePictureURL]];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:profilePictureURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:4.0f];
NSURLConnection *urlConnection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
if (!urlConnection) {
NSLog(@"Failed to Download Picture");
}
}
}];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[self.imageData appendData:data];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
UIImage *profileImage = [UIImage imageWithData:self.imageData];
[self uploadPFFileToParse:profileImage];
}
@end
最佳答案
在这一行中:
[photo setObject:photo forKey:kCCPhotoPictureKey];
您将 photo
对象设置为引用自身。我猜这是一个创建循环引用的拼写错误,你真的想要:
[photo setObject:photoFile forKey:kCCPhotoPictureKey];
关于iOS - NSInternalInconsistencyException 'circular dependency when saving',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21686407/
环形缓冲区和循环链表有什么区别? Ring Buffer 的目的是什么,而循环链表不能,反之亦然? 最佳答案 环形缓冲区是一个连续的内存块,其中包含您的项目,当您到达终点时,您会循环回到起点: +--
我有一个像这样的多级依赖关系图,我需要检测该图中的任何循环引用。 A = B 乙=丙 C = [D, B] D = [C, A] 有人有这样的问题吗? 有什么解决办法??? 用英语表示感谢和抱歉。 =
尝试编写一个reduce函数来过滤掉任何重复项。我知道还有其他方法可以解决这个问题,但我正在尝试练习递归函数。 function addToSet(a, b) { a.add(b); retu
我想知道是否有人已经实现/知道(最好是 javascript)将处理循环间隔的间隔树算法。通过循环,我的意思是开始 > 结束的间隔。请注意,这也需要限制间隔的大小。 这只是常见区间树问题的一个子案例吗
我有一段代码,其中声明了两种数据类型。我已经将两者都自动派生为类型类 enum 的成员,但是,我不喜欢它们不是“圆形”的。我的意思是调用 succ Sun应该让我Mon . succ Dec应该导致
运行此代码时: function arrayToList(arr) { if (arr.length == 1) { return { value: arr[0],
我有以下模块结构: /components ├── Button.js ├── Checkbox.js ├── index.js ├── DateSelect ├── DateSelect.j
为了检查光线与三角形的碰撞,我们可以首先查看光线是否与三角形的平面发生碰撞。如果是,我们然后检查所有三角形边的交点是否在同一边。如果为真,则意味着该点位于三角形内部。此过程与矩形和其他凸图形类似。 这
我遇到了同样的问题,如下所示: NHibernate - not-null property reference a null or transient value 根本原因就像 Alun Harfo
我想以“循环”方式使用函数,如下例所示: fun cll1 (s)= cll2(s); fun cll2 (s)= cll3(s); fun cll3 (s)= cll(s); 编写此代码会在 SML
我想根据现有列的滞后值在 pyspark.sql.DataFrame 中创建一个新列。但是......我也希望最后一个值成为第一个值,第一个值成为最后一个值。这是一个例子: df = spark.cr
我正在使用 Microsoft.ServiceModel.Samples.CircularTracecListener 二进制文件来实现 Web 服务上的错误日志记录。 它应该写入一个文件,直到达到
我有一个由 8 个罗盘点组成的数组,从 SW 顺时针编号到 S: 2 3 4 1 5 0 7 6 我想计算从一点到另一点的最短路线是顺时针 (+1) 还是逆时针 (-1)。例如。从 7 到 5 是
我知道如何解决基本的循环依赖示例,有两个类,每个类都需要知道另一个存在。 但是,我现在的情况是,示例更复杂,前向声明不是可以解决该问题的东西。 考虑这三个文件 // my_thread.hpp tem
我正在开发一款用于在线播放歌曲的应用程序。我可以通过点击播放这首歌。 我的问题是我在所有 Activity 中都有一个 CircularSeekBar,我需要在所有屏幕上管理它。如果从任何 Activ
我正在尝试实现动画 shown here .它工作正常,除了 unreveal 动画,显示黑屏片刻。并非所有设备/api 版本都存在该故障。 Google Nexus 10 (API 22) 的 Ge
我正在使用 Canvas 创建倒数计时器循环,但有一个简单的问题,我需要将天数除以 364 天,当天数大于 364 天时,天数消失: 我需要的是这样的: (function($) { jQuery
我想在不使用 SVG 的情况下实现这样的效果: https://codepen.io/arforcee/pen/erbKi?limit=all&page=2&q=circular+loader 这是否
这个问题在这里已经有了答案: How to create a circle with links on border side (8 个答案) 关闭 4 年前。
我遇到了一个小设计问题。 如下情况 库界面 包含每个模型类的接口(interface)(仅限 getter 和 setter) 图书馆业务逻辑 包含接口(interface)库和 DAL 的实现。使用
我是一名优秀的程序员,十分优秀!