Forum Navigation
You need to log in to create posts and topics.

Re: Getting the Max number from a set of numbers

Posted by: kashmidheiser <kashmidheiser@...>

Back to Rich's original post in this thread he asked:


The following works in Objective-C

But how is this done in FutureBasic? (without using a C Function)

NSArray *unsortedArray = @[ @2, @44, @11, @99, @35 ];

NSNumber *maxNumber = [unsortedArray valueForKeyPath:@"@max.self"];

NSLog(@"%@", maxNumber); // 99

Here's the answer, I just wish I could claim this as my own. 😀

We took the long way around to get here, but it was fun!

Ken

include "NSLog.incl"

local fn DoIt
CFArrayRef unsortedArray = @[@2,@44,@99,@35]
CFNumberRef maxNumber = fn ObjectValueForKeyPath( (ObjectRef)unsortedArray, @"@max.self" )
NSLog(@"%@",maxNumber)
end fn

fn DoIt

HandleEvents



--
To unsubscribe, send ANY message to: futurebasic-unsubscribe@freegroups.net To access the list archives, go to: http://freegroups.net/groups/futurebasic/