Re: [Pyobjc-dev] Bridging of Strings
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2002-12-30 06:44:08
|
On Monday, Dec 30, 2002, at 01:15 Europe/Amsterdam, David Eppstein wrote: > On 12/23/02 8:30 PM +0100 Ronald Oussoren <ous...@ci...> wrote: >>> ValueError: NSInvalidArgumentException - *** -count only defined for >>> abstract class. Define -[NSCFArray count]! >>> >> >> That's just like in 'normal' python types: If you call NSArray.count >> you >> get the count method defined by NSArray instead of the one defined by >> the class of your object. That is not very Objective-C-like, but >> this is >> needed to implement super(cls, self).count(). > > A possibly related recent surprise I had: > I had an NSArray object X (or its Python proxy) and attempted to > retrieve X[-1]. > Got an NSRangeError rather than the expected last array item. > Trivial to work around, but shouldn't this work? Yup, it's a bug. I'll check in a fix later today. > >> That's not really a problem, just use the strint literal >> "localizedCaseInsentiveCompare:" as the argument off >> NSArray.sortedArrayUsingSelector_. By the time strings NSArray methods >> touch the strings in an array they will be converted to NSString >> (that's >> even true if the NSArray is the OC_PythonArray proxy for a python >> sequence). > > Well, except that what I really want to sort isn't an NSArray of > strings, it's a Python list of Python dictionaries, which I want to > sort according to the (localized case-independent) string values > stored under one of the keys in each dictionary. It will be possible to use 'NSString.localizedCaseInsensitiveCompare_("foo", "bar")' in the next release. Until that time you could use the workaround described by Bill. Or if your brave you could use the CVS version that already contains this update ;-). Ronald |