[Pyobjc-dev] always replace colons with underscores... most of the time
Brought to you by:
ronaldoussoren
|
From: Chris M. <pyo...@mc...> - 2007-11-11 21:23:48
|
Consider the following in objective-c:
@interface Person : NSObject {
NSString *personName;
float expectedRaise;
}
- (float)expectedRaise;
- (void)setExpectedRaise:(float)x;
- (NSString *)personName;
- (void)setPersonName:(NSString *)aName;
@end
It would make sense to implement it in python as follows:
class Person(NSObject):
personName = objc.ivar()
expectedRaise = objc.ivar.float()
def setExpectedRaise_(self, expectedRaise):
self.expectedRaise = expectedRaise
def setPersonName_(self, personName):
self.personName = personName
It looks like it should work fine for KVC, however the trailing
underscores on the setAttribute_ calls are not valid. If you replace
the colons in the objective-c calls with underscores in python as I
have seen else where, you will get an error when using KVC via an
NSArrayController.
An unexpected error occured: (AttributeError: 'Person' object has no
attribute 'setExpectedRaise')
This is resolved when removing the trailing underscore from the method
call.
Is this an exception to the replace colons in objective-c with
underscores in python rule?
-chris
|