Re: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Markus Spoettl

On Jun 28, 2008, at 5:07 PM, Quincey Morris wrote:
The last-modified date on that page is Feb, 2007. Seems like a long  
time for such a fundamental document to be incomplete. That may be a  
good thing to mention when you file a bug report against the  
documentation. ;)



Done, 6042235.

Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Quincey Morris


On Jun 28, 2008, at 16:38, Markus Spoettl wrote:


On Jun 28, 2008, at 4:06 PM, Clark Cox wrote:

They're listed in the NSKeyValueCoding.h header, but it seems that
they aren't included in the equivalent documentation
().



That's it! This is what the comment for NSMutableArray says. In the  
first paragraph notice that -insert:atIndexes: and - 
removeAtIndexes: is not in the documentation.


The last-modified date on that page is Feb, 2007. Seems like a long  
time for such a fundamental document to be incomplete. That may be a  
good thing to mention when you file a bug report against the  
documentation. ;)





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Markus Spoettl

On Jun 28, 2008, at 4:06 PM, Clark Cox wrote:

They're listed in the NSKeyValueCoding.h header, but it seems that
they aren't included in the equivalent documentation
().



That's it! This is what the comment for NSMutableArray says. In the  
first paragraph notice that -insert:atIndexes: and - 
removeAtIndexes: is not in the documentation.


Thanks Clark!

Regards
Markus

From NSKeyValueCoding.h:

1. Searches the class of the receiver for methods whose names  
match the patterns -insertObject:inAtIndex: and - 
removeObjectFromAtIndex: (corresponding to the two most primitive  
methods defined by the NSMutableArray class), and (introduced in Mac  
OS 10.4) also -insert:atIndexes: and -removeAtIndexes:  
(corresponding to -[NSMutableArray insertObjects:atIndexes:] and - 
[NSMutableArray removeObjectsAtIndexes:). If at least one insertion  
method and at least one removal method are found each NSMutableArray  
message sent to the collection proxy object will result in some  
combination of -insertObject:inAtIndex:, - 
removeObjectFromAtIndex:, -insert:atIndexes:, and - 
removeAtIndexes: messages being sent to the original receiver of - 
mutableArrayValueForKey:. If the class of the receiver also implements  
an optional method whose name matches the pattern - 
replaceObjectInAtIndex:withObject: or (introduced in Mac OS 10.4)  
-replaceAtIndexes:with: that method will be used when  
appropriate for best performance.
2. Otherwise (no set of array mutation methods is found),  
searches the class of the receiver for an accessor method whose name  
matches the pattern -set:. If such a method is found each  
NSMutableArray message sent to the collection proxy object will result  
in a -set: message being sent to the original receiver of - 
mutableArrayValueForKey:.
3. Otherwise (no set of array mutation methods or simple accessor  
method is found), if the receiver's class'  
+accessInstanceVariablesDirectly method returns YES, searches the  
class of the receiver for an instance variable whose name matches the  
pattern _ or , in that order. If such an instance variable  
is found, each NSMutableArray message sent to the collection proxy  
object will be forwarded to the instance variable's value, which  
therefore must typically be an instance of NSMutableArray or a  
subclass of NSMutableArray.
4. Otherwise (no set of array mutation methods, simple accessor  
method, or instance variable is found), returns a mutable collection  
proxy object anyway. Each NSMutableArray message sent to the  
collection proxy object will result in a -setValue:forUndefinedKey:  
message being sent to the original receiver of - 
mutableArrayValueForKey:. The default implementation of - 
setValue:forUndefinedKey: raises an NSUndefinedKeyException, but you  
can override it in your application.


--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Clark Cox
On Sat, Jun 28, 2008 at 3:53 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
> On Jun 28, 2008, at 1:03 PM, Kyle Sluder wrote:
>>
>> And you're surprised that this caused an infinite loop?
>
> As a matter of fact, yes I was until I realized what was happening. I read
> the documentation and there was no mention about this specific accessor.
> That was not the question, though, only an explanation of what has happened
> and why I asked the question I am asking.
>
> The real question is if there is a list of accessor methods that can be
> implemented optionally so you don't run into this accidentially as I did.

They're listed in the NSKeyValueCoding.h header, but it seems that
they aren't included in the equivalent documentation
().

-- 
Clark S. Cox III
[EMAIL PROTECTED]
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Keary Suska
6/28/08 4:53 PM, also sprach [EMAIL PROTECTED]:

> The real question is if there is a list of accessor methods that can
> be implemented optionally so you don't run into this accidentially as
> I did.

http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Con
cepts/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830-BAJEDEFB

It's not a list per se, but does reference every accessor. For more info on
the various methods in a more listy kind of way, refer to the protocol doc:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Protocol
s/NSKeyValueCoding_Protocol/Reference/Reference.html

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Markus Spoettl

On Jun 28, 2008, at 1:03 PM, Kyle Sluder wrote:

And you're surprised that this caused an infinite loop?


As a matter of fact, yes I was until I realized what was happening. I  
read the documentation and there was no mention about this specific  
accessor. That was not the question, though, only an explanation of  
what has happened and why I asked the question I am asking.


The real question is if there is a list of accessor methods that can  
be implemented optionally so you don't run into this accidentially as  
I did.


Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Kyle Sluder
On Sat, Jun 28, 2008 at 3:56 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
> I had this in my code
>
> - (void)removeAtIndexes:(NSIndexSet *)indexes
> {
>NSMutableArray *kva = [self mutableArrayValueForKey:@""];
>[kva removeObjectsAtIndexes:indexes];
> }

And you're surprised that this caused an infinite loop?  The point of
the indexed accessors is to implement the actual data manipulation for
the proxy returned by -mutableArrayValueForKey.  So all
-removeKeyAtIndexes: should do is remove the requested object from
whatever storage mechanism is being used to back that property.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Markus Spoettl

Hello List,

  is there a complete list of indexed accessor names that can be  
implemented? The KVC guides just mentions the basic ones


- (NSUInteger)countOf
- (id)objectInAtIndex:(unsigned)theIndex
- (void)get:(id *)objsPtr range:(NSRange)range
- (void)insertObject:(id)obj inAtIndex:(NSUInteger)theIndex
- (void)removeObjectFromAtIndex:(NSUInteger)theIndex
- (void)replaceObjectInAtIndex:(NSUInteger)theIndex withObject: 
(id)obj


I had this in my code

- (void)removeAtIndexes:(NSIndexSet *)indexes
{
NSMutableArray *kva = [self mutableArrayValueForKey:@""];
[kva removeObjectsAtIndexes:indexes];
}

which caused an endless recursion because [kva  
removeObjectsAtIndexes:] assumes that removeAtIndexes: is the KVC  
implementation for it. Of course it was not. I can't find any mention  
in the documentation about this accessor name.


So, is there complete list of method names or is it just all  
NSMutableArray methods that contain "Objects" in their name with  
"Objects" replaced by "" ?


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]