Friday, July 20, 2018

#1 2009-10-26 01:46:21 pm

Registered: 2005-06-23
Posts: 152


Here is an extract from the Apple Cocoa Documentation regarding NSNotFound.

Prior to Mac OS X v10.5, NSNotFound was defined as 0x7fffffff. For 32-bit systems, this was effectively the same as NSIntegerMax. To support 64-bit environments, NSNotFound is now formally defined as NSIntegerMax. This means, however, that the value is different in 32-bit and 64-bit environments. You should therefore not save the value directly in files or archives. Moreover, sending the value between 32-bit and 64-bit processes via Distributed Objects will not get you NSNotFound on the other side. This applies to any Cocoa methods invoked over Distributed Objects and which might return NSNotFound, such as the indexOfObject: method of NSArray (if sent to a proxy for an array).

I have come across this in converting some code from ObjC to ASOC where it is used as follows:


   for (index = [indexes lastIndex]; index != NSNotFound; index = [indexes indexLessThanIndex:index])
       if (index < destinationIndex)
           destinationIndex --;    
       id obj = [images objectAtIndex:index];
       [temporaryArray addObject:obj];
       [images removeObjectAtIndex:index];

Does anyone know the correct way to use NSNotFound in ASOC?





#2 2009-10-26 04:39:05 pm

Shane Stanley
From:: Australia
Registered: 2002-12-07
Posts: 5410

Re: NSNotFound

Unless you have a chance of hitting such high numbers, in which case good luck with ASObjC, you could probably just test for greater than 0x7fffffff - 1 -- that would catch either eventuality.

Shane Stanley <>



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)