[Pyobjc-dev] Translator needed to begin my journey
Brought to you by:
ronaldoussoren
From: Matt L. <jm...@gm...> - 2009-06-10 07:20:16
|
Hey guys, I am trying to learn Objective-C. All of my current programming background is in Python and this new syntax isn't sitting well with me. I have been reading tons of documentation and seen loads of tutorial videos, but I'm just not quite picking it up yet. I would be really appreciative if someone could translate this sample Python code into ObjC so I can make all the connections in my head. I think it will give me the kick start I really need to dive deeper into the language. Please be sure to include both header and implementation so I can see the whole picture. Thanks in advance! #!/usr/bin/python # This section to show class and method structure class Employee(object): def __init__(self, name, salary): self.name = name self.salary = salary def nameUpper(self): return self.name.upper() def giveRaise(self, percent): self.salary *= (1.0 + percent) # This section to show normal function structure def printHeader(): print 'Company HR' print '-' * 20 print '' def main(): printHeader() matt = Employee('Matt', 100000) print matt.nameUpper() print (%s: %d) % ('Old Salary', matt.salary) matt.giveRaise(.20) print (%s: %d) % ('New Salary', matt.salary) if __name__ == '__main__': main() |