Facebook 参数问题导致应用程序终止 - iPhone
我尝试从 iPhone 应用程序向 Facebook 发帖,但不起作用。
这就是我正在做的:
if (![_facebook isSessionValid])
{
NSArray *permissions = [NSArray arrayWithObjects:
@"read_stream", @"publish_stream", @"offline_access",nil];
[facebook authorize:permissions delegate:self];
}
NSMutableDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:
@"User Prompt Message", @"user_message_prompt",
@"http://www.mywebsite.com/", @"link",
@"http://mywebsite.com/wp-content/uploads/2011/05/iTunesArtwork.png", @"picture",
nil];
[facebook requestWithGraphPath:@"me/feed"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
我也尝试过
[self.facebook 对话框:@"feed" andParams:params andDelegate:self];
但无论哪种情况,我的应用程序都会被终止
- (FBRequest*)openUrl:(NSString *)url 参数:(NSMutableDictionary *)参数 httpMethod:(NSString *)httpMethod 委托:(id)委托
或在
- (void)对话框:(NSString *)操作 andParams:(NSMutableDictionary *)params andDelegate:(id )委托
取决于我使用此日志调用的方法:
* 由于未捕获的异常而终止应用程序 'NSInternalInconsistencyException',原因:'-[__NSCFDictionary setObject:forKey:]:发送到不可变对象的变异方法'
这对我来说没有意义,因为正在使用的字典是可变的。
我做错了什么吗?任何帮助将不胜感激。
I am trying to post to Facebook from my iPhone app and it just doesn't work.
This is what I am doing:
if (![_facebook isSessionValid])
{
NSArray *permissions = [NSArray arrayWithObjects:
@"read_stream", @"publish_stream", @"offline_access",nil];
[facebook authorize:permissions delegate:self];
}
NSMutableDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:
@"User Prompt Message", @"user_message_prompt",
@"http://www.mywebsite.com/", @"link",
@"http://mywebsite.com/wp-content/uploads/2011/05/iTunesArtwork.png", @"picture",
nil];
[facebook requestWithGraphPath:@"me/feed"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
I also tried
[self.facebook dialog:@"feed" andParams:params andDelegate:self];
but in either case my app is getting terminated either in
- (FBRequest*)openUrl:(NSString *)url
params:(NSMutableDictionary *)params
httpMethod:(NSString *)httpMethod
delegate:(id)delegate
or in
- (void)dialog:(NSString *)action
andParams:(NSMutableDictionary *)params andDelegate:(id
)delegate
depending on which method I call with this log:
* Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: '-[__NSCFDictionary
setObject:forKey:]: mutating method sent to immutable object'
It doesn't make sense to me because the dictionaries being used are mutable.
Am I doing something wrong? Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,他们不是。尽管您将返回的对象分配给
NSMutableDictionary
变量,但您还是在此处创建NSDictionary
:这应该是:
这可能是崩溃的原因:
,因为 Facebook API 需要一个可变字典:
No, they are not. Despite that you are assigning the returned object to a
NSMutableDictionary
variable, you are creating aNSDictionary
here:This should be:
This is likely the cause of the crash:
because the Facebook API expects a mutable dictionary: