小编Mat*_*att的帖子

成功查看RestKit后获取Null值

我相信我正在跳过一个重要的步骤或者说我的财产是错误的.在我的应用程序中,在使用登录信息创建POST对象后,我无法使用映射对象中的此信息(这意味着我得到空值).我假设在创建post请求和响应请求之后,我应该能够使用我的NSObjectClass中保存的值.

我的问题

在发布请求映射后如何保存值?如果有人可以提供一个如何使用response.body值的示例,那将非常有用.谢谢.

我的课程

#import <Foundation/Foundation.h>

@interface AccountsClass : NSObject

@property (nonatomic, strong)           NSString *DeviceType;
@property (nonatomic,strong)            NSString *HardwareId;
@property (nonatomic,strong)            NSString *NickName;
@property (nonatomic,strong)            NSNumber *HelpCreditsBalance;
@property (nonatomic,assign)            BOOL GotRatingCreditBonus;
@property (nonatomic,strong)            NSNumber *AccountId;
@end
Run Code Online (Sandbox Code Playgroud)

这是我用于POST请求的方法

-(void)loadPostRequest 
{

    _StoreIdentifierForVendor = [[[UIDevice currentDevice]identifierForVendor]UUIDString];
    _StoreTheModel = [UIDevice currentDevice].model;
    _nickname = usernameTextField.text;

    AccountsClass *AccountInfo = [[AccountsClass alloc] init];
    AccountInfo.NickName = _nickname;
    AccountInfo.HardwareId =_StoreIdentifierForVendor;
    AccountInfo.DeviceType =_StoreTheModel;
    AccountInfo.AccountId =nil;
    AccountInfo.GotRatingCreditBonus = FALSE;
    AccountInfo.HelpCreditsBalance = nil;

    //this is where the POST request begins

    RKObjectMapping *responseMapping …
Run Code Online (Sandbox Code Playgroud)

objective-c ios restkit

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

使用Restkit 0.20进行映射此类不是密钥的符号编码兼容性

您好我使用restkit从api映射数据有问题.我有以下数据.我非常感谢任何可以指出我的错误的人.

{"GameId":1,"Items":

[{"Id":1,"PicUrl":"someurlhere","Answers":

["Paris","New York","San Francisco","Rome"],"CorrectAnswer":"San Francisco","Categories"}]}
Run Code Online (Sandbox Code Playgroud)

这就是我计划在客户端存储数据的方式:

#import <Foundation/Foundation.h>

GameObjects.h

    @interface GameObjects : NSObject
    @property(nonatomic, strong)NSNumber *GameId;
    @property(nonatomic,strong)NSMutableArray *Items;
    @property(nonatomic,strong)NSNumber *IId;
    @property(nonatomic,strong)NSURL *PicUrl;
    @property(nonatomic,strong)NSMutableArray *Answers;
    @property(nonatomic,strong)NSString *CorrectAnswer;
    @property(nonatomic,strong)NSString *CategoryName;
    @end



GameObjects.m

#import "GameObjects.h"

@implementation GameObjects
@synthesize GameId;
@synthesize Items;
@synthesize Answers;
@synthesize IId;
@synthesize CategoryName;
@synthesize CorrectAnswer;
@synthesize PicUrl;
- (id)init
{
    self = [super init];
    if (self) {

        Items = [[NSMutableArray alloc]initWithObjects:PicUrl,Answers,CorrectAnswer,CategoryName, nil];

    }
    return self;
}

@end
Run Code Online (Sandbox Code Playgroud)

这就是我如何进行映射:

-(void)viewDidLoad
{

    //restkit
    RKObjectMapping *GameMapping = [RKObjectMapping mappingForClass:[GameObjects class]]; …
Run Code Online (Sandbox Code Playgroud)

objective-c ios restkit restkit-0.20

0
推荐指数
1
解决办法
3070
查看次数

标签 统计

ios ×2

objective-c ×2

restkit ×2

restkit-0.20 ×1