我的应用程序中有一个JSON解析器,我将值加载到detailDataSourceDict变量中.当我尝试获取数组的valueForKey并尝试将其与0进行比较时,它永远不会...
这是我的代码:
if (indexPath.row == 1) {
NSNumber *rating = [detailDataSourceDict valueForKey:@"rating"];
NSLog(@"Rating: %@",rating);
if (rating == 0) {
cell.detailTextLabel.text = @"This sheet has not yet been rated.";
}
else {
cell.detailTextLabel.text = [NSString stringWithFormat:@"This sheet has a %@ star rating.",rating];
}
cell.textLabel.text = @"Rating";
}
Run Code Online (Sandbox Code Playgroud)
我在我的JSON Feed中看到"评级":"0",但是当评级为0时,它显示"此表格有0星评级."而不是"此表尚未评级".
有什么建议?谢谢.
我有一个视图,其上有tableviewcells,加载了不同的"键值"作为标签.当我点击一个时,我打开另一个视图.但是在这里,我只传递了那个键的字典,例如我会传递这个:
{
key = Budget;
value = {
"2012 Budget Report" = {
active = 0;
author = "xxxxx xxxxxx";
date = "October 27, 2012";
description = "Example";
dl = "53 downloads";
email = "xxx@xxxxx.com";
ext = DOCX;
fortest = "Tuesday, November 6";
id = 5;
subject = budget;
testdate = "Tuesday, November 6";
title = "Budget spreadSheet";
};
"2005 - 2008 Budget Report" = {
active = 0;
author = "xxxxxxx xxxxx";
date = "November 3, 2012";
description = …Run Code Online (Sandbox Code Playgroud) 这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSArray *filePathsArray = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:documentsDirectory error:nil];
NSMutableArray *finalArray = [(NSArray*)filePathsArray mutableCopy];
NSFileManager *fm = [NSFileManager defaultManager];
NSArray *files = [fm contentsOfDirectoryAtPath:documentsDirectory error:nil];
NSString *fileFirst = [files objectAtIndex:0];
NSString *fullPath = [NSString stringWithFormat:@"%@/%@", documentsDirectory, fileFirst];
/* NSUInteger index = [finalArray indexOfObject:@".DS_Store"];
[finalArray removeObjectAtIndex: index]; */
//NSLog(@"files array %@", finalArray);
NSString …Run Code Online (Sandbox Code Playgroud)