小编178*_*040的帖子

比较NSNumber到0不工作?

我的应用程序中有一个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星评级."而不是"此表尚未评级".

有什么建议?谢谢.

json objective-c nsnumber

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

在foreach中获取NSDictionary的值?

我有一个视图,其上有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)

json nsdictionary ios

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

使用imageNamed在设备上失败,但在模拟器中工作

这是我的代码:

    - (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)

objective-c uiimage ios

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

标签 统计

ios ×2

json ×2

objective-c ×2

nsdictionary ×1

nsnumber ×1

uiimage ×1