我基本上是想这样做;
// Catch the true/false flag and convert to BOOL value for server
NSString *on = [prefs objectForKey:@"published"];
BOOL flag = TRUE;
if ([on isEqualToString:@"true"])
{
flag = TRUE;
}
else
{
flag = FALSE;
}
NSArray *objects = [NSArray arrayWithObjects:body, flag, user_token, request_token, deviceID, api_user, nil];
NSArray *keys = [NSArray arrayWithObjects:@"selections", @"published", @"user_token", @"request_token", @"device_id", @"api_user", nil];
NSDictionary *questionDict = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
Run Code Online (Sandbox Code Playgroud)
哪个检查prefs是否为true,如果是,则转换为BOOL值为true等.
然而它崩溃说它缺少对象的对象数量.
这样做有什么帮助吗?
我正在做一个小计算,但它总是返回0 ..
int totalBothTeams = [prefs integerForKey:@"totalTimeBothTeams"];
int someCalculation = (totalBetween / totalBothTeams) * 100;
NSLog(@"Time: %i", someCalculation);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
救命!我已经用这个问题把头发拉了1个小时了.
我正在我的.h文件中创建一个数组
@interface LeftMenuViewController : UIViewController <UITableViewDataSource, UITabBarControllerDelegate>
@property (strong, nonatomic) MKNetworkOperation *myNetworkOperation;
@property (strong, nonatomic) NSArray *listOfClubsArray;
@end
Run Code Online (Sandbox Code Playgroud)
然后我从JSON中的API调用中提取项目列表
///////////////////////////////////////////
#pragma mark Retreive List of Clubs / Teams
///////////////////////////////////////////
- (void)getListOfClubs {
// Because we have a success from login auth we will now make a seperate call to gather club details
self.myNetworkOperation = [app.teamManagerWrapper deviceID:@"adam" userToken:@"sdfdfgf" onCompletion:^(NSDictionary *result) {
NSDictionary *data2 = [result objectForKey:@"data"];
self.listOfClubsArray = [data2 objectForKey:@"user_clubs"];
[self.tableView reloadData];
} onError:^(NSError *error) {
// error none
}]; …Run Code Online (Sandbox Code Playgroud)