小编clo*_*pez的帖子

使用RESTKit做一个简单的json POST

我是iOS开发的新手,我在制作一个简单的Json POST请求时遇到了麻烦.我有一个包含用户和密码的NSDictionary,我想将这些值作为Json发送到服务器并获得响应.我没有使用restkit工作,但我无法弄清楚如何使用RestKit完成相同的工作,只是找不到我想要的好例子.

- (bool) login{

    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
    [params setValue:self.email forKey:@"email"];
    [params setValue:self.password forKey:@"password"];    

    NSMutableDictionary* rpcData = [[NSMutableDictionary alloc] init];
    [rpcData setValue:@"2.0" forKey:@"jsonrpc"];
    [rpcData setValue:@"authenticate" forKey:@"method"];
    [rpcData setValue:@"" forKey:@"id"];
    [rpcData setValue:params forKey:@"params"];

    [[RKClient sharedClient] post:@"/api/rpc/" params:rpcData delegate:self];
    return nil;
}
Run Code Online (Sandbox Code Playgroud)

服务器期待像这样的Json:

{
    jsonrpc : '2.0',
    method : 'authenticate', // method name goes here
    params : {  // params are method-specific
        email : 'test@test.com',
        password : 'secret'
    },
    id : 2  // The id can be anything, it …
Run Code Online (Sandbox Code Playgroud)

post cocoa-touch json objective-c restkit

18
推荐指数
2
解决办法
2万
查看次数

ACAccountStore错误6(ACErrorAccountNotFound)和8

我正在尝试使用以下代码从ACAccountStore获取帐户:

- (void) facebookLoginOnSuccess: (void (^)(void)) successBlock onError:(void(^)(NSError *error))errorBlock{

    self.facebookPermissions = @[
        @"offline_access",
        @"publish_stream",
        @"user_birthday",
        @"user_location",
        @"email"
    ];


    NSDictionary *options = @{
        @"ACFacebookAppIDKey": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FacebookAppID"],
        @"ACFacebookAppVersionKey": @"1.0",
        @"ACFacebookPermissionsKey": self.facebookPermissions,
        @"ACFacebookPermissionGroupKey": @"write"
    };

    [self accountLoginFor:ACAccountTypeIdentifierFacebook withOptions:options OnSuccess:successBlock onError:errorBlock];

}

- (void) accountLoginFor: (NSString *) accountTypeID withOptions: (NSDictionary *) options OnSuccess: (void (^)(void)) successBlock onError:(void(^)(NSError *error))errorBlock{

    ACAccountStore *accountStore = [[ACAccountStore alloc] init];
    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:accountTypeID];

    [accountStore requestAccessToAccountsWithType:accountType
                                          options:options
                                       completion:^(BOOL granted, NSError *error){
        if (granted){
            NSArray *accountsArray = [accountStore accountsWithAccountType:accountType]; …
Run Code Online (Sandbox Code Playgroud)

ios ios6

10
推荐指数
1
解决办法
1万
查看次数

来自Github的Facebook iOS SDK 3.1缺少FacebookSDK.framework

我想在XCode 4.5上使用Facebook SDK与iOS6集成.

我读了这个教程.我正在使用这个.dmg软件包来安装库,但是我需要跟踪和阅读一些方法的实现,所以我注意到Github上有一个包含当前源代码的repo .

我的问题是我不知道如何正确安装这个包.dmg.关于如何做的任何想法?我试图导入src文件夹并引用整个项目,但我遇到了很多问题,警告和错误.

更新

我不得不再次这样做,所以现在我做到了.这是我做的:

我尝试了两种方法,构建源代码(1)并直接导入文件(2).在第一个场景很容易,在Github repo的根文件夹上运行:

sudo scripts/build_framework.sh
Run Code Online (Sandbox Code Playgroud)

您将获得所需的文件,与使用.pkg安装时获得的文件相同.但我需要跟踪功能,所以我尝试导入文件.

首先,我在我的项目中添加了Github repo中的src文件夹.我遇到了每个文件都有重复定义的问题.问题出在我的Build Settings(BS)上,我还在引用Facebook的.pkg安装目录,所以我把文件复制了.我删除了BS上对该文件夹的每个引用,然后添加了文件.

之后,在我导入的Facebook文件的文件中:

Undefined symbols for architecture i386
Run Code Online (Sandbox Code Playgroud)

当我将文件复制到XCode时,.m文件不会自动添加到Build Phases/Compile Sources.我手动添加它们并在我的文件上导入FBConnect.h.

希望它可以帮助某个人有同样的问题.

facebook ios ios6

6
推荐指数
1
解决办法
3888
查看次数

iOS 5 Storyboard评论

有没有办法在iOS故事板上添加评论?目前我们有一个项目,其中有几个人在同一个界面上工作,能够在故事板本身写入是非常有帮助的,所以你可以给别人留言或者把东西记下来.

像气泡一样的东西,如"马克,请修复退出按钮,将其更改为红色".有这样的事吗?我找不到它.

comments ios uistoryboard

5
推荐指数
1
解决办法
389
查看次数

标签 统计

ios ×3

ios6 ×2

cocoa-touch ×1

comments ×1

facebook ×1

json ×1

objective-c ×1

post ×1

restkit ×1

uistoryboard ×1