Re: [Pyobjc-dev] Translator needed to begin my journey
Brought to you by:
ronaldoussoren
From: Matt L. <jm...@gm...> - 2009-06-10 17:36:51
|
Barry, you cant begin to know how helpful that is! Thank you so much! I really appreciate the level of detail and the helpful tips and info inside the code. I have just glanced over the files and it already makes 100% more sense to me. I cant wait to start learning and coding more. Thanks again! Matt On Wed, Jun 10, 2009 at 11:20 AM, Barry Wark <bar...@gm...> wrote: > Matt, > > I've attached the thee (!) files that translate your code as well as > an Xcode project to build and run them. I've made use of the > Objective-C 2.0 @property and @synthesized getters/setters. In this > case you could get away with using the instance variables directly > (though this is bad practice in ObjC because it exposes the > implementation and it's hard to convert to properties later, unlike > Python). > > Cheers, > Barry > > > On Wed, Jun 10, 2009 at 12:18 AM, Matt Lott<jm...@gm...> wrote: > > 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() > > > > > > > > > > > > > ------------------------------------------------------------------------------ > > Crystal Reports - New Free Runtime and 30 Day Trial > > Check out the new simplified licensing option that enables unlimited > > royalty-free distribution of the report engine for externally facing > > server and web deployment. > > http://p.sf.net/sfu/businessobjects > > _______________________________________________ > > Pyobjc-dev mailing list > > Pyo...@li... > > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > > > |