Search code examples
iosxcodensnumber

What is the Use of "NSNumber numberWithInt" in Xcode


i'm retrieving data from server - where the NS Number used contains BOOL value in database format. but when i try to use TRUE or FALSE , it doest allow to do. - i'm a Beginner of Xcode.

for (unsigned int i =0; i<studentDashBoardDetails.count; i++) {

            // Early CheckOut Days
    if ([[[ studentDashBoardDetails objectAtIndex:i]objectForKey:@"dayType"]isEqualToString: @"Working"]&&[[[studentDashBoardDetails objectAtIndex:i]objectForKey:@"isAttended"]isEqualToNumber:[NSNumber numberWithInt:1]]&&[[[studentDashBoardDetails objectAtIndex:i]objectForKey:@"timeSpent"]isLessThan:@"08.00.00"])
        {
            NSLog(@" Early Check out on   %@",[[studentDashBoardDetails objectAtIndex:i]objectForKey:@"attendanceDate"]);

Solution

  • NSNumber numberWithInt returns the signed integer for the current value, to access bool values you can use NSNumber numberWithBool method, it creates an object and returns NSNumber which can be treated as a bool.

    I hope it will help you in achieving proper way on how to solve your problem