Karan Bhatia
Karan Bhatia

Reputation: 907

valueForKeyPath: @"@max.self" returning nil for iOS 9.3.5?

I am trying to find out maximum value from an array using @"@max.self" but it is returning nil when I try to run it on iOS 9.3.5 device, for the Higher version it works properly and returns the proper value.

NSNumber *maxOfBarGraphValues = [arrayOfBarGraphValues valueForKeyPath:@"@max.self"];

 NSLog(@"%@",[[arrayOfBarGraphValues valueForKeyPath: @"@max.self"]floatValue] );

Below I am attaching output for the NSLog statement and value of arrayOfBarGraphValues from the console.

Printing description of self->arrayOfBarGraphValues: <__NSArrayM 0x16e1ffc0>
( 
5,
4,
7,
7,
6,
6,
7,
7,
7,
7,
7,
7,
7 
)

(lldb) po maxOfBarGraphValues  
nil

Upvotes: 0

Views: 147

Answers (1)

BuLB JoBs
BuLB JoBs

Reputation: 871

Follow this code hope will helpful to you.

NSArray *  arrayOfBarGraphValues = @[@5, @4, @7 ,@7 , @6, @6  ,@7  ,@7  ,@7  ,@7  ,@7  ,@7  ,@7 ];
int maxOfBarGraphValues = [[arrayOfBarGraphValues valueForKeyPath: @"@max.self"] intValue];
NSLog(@" MaximumValue Of BarGraph  = %d", maxOfBarGraphValues);

Output:- // Maximum = 7

Upvotes: 0

Related Questions