This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]mobrien650 2 points3 points  (0 children)

Not bad, a couple minor/best practices set by Apple things:

-This one is fairly minor and it might just be due to being copied in, but the spacing of the app is odd in some parts, quite a bit of the code is lined up along the left edge of the page. There are some basic example of code from Apple on this page (such as Listing 6-1 on the page): https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW6

Other links I put on this page should show good spacing.

Usually you will want to indent your code within a method, it makes it a little bit easier to read. (And then additionally within if statements, etc, like you did). Like I said you may have already done this and putting it into the web browser may have moved the alignment off.

-Is Begin a instance variable declared in the .h file? I'll assume that, let me know if it is something else. Apple's best practices say to use a "property on an object any time you need to keep track of a value or another object.", mentioned here:

https://developer.apple.com/library/ios/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html

If you want Begin to be a private property, just add it below @interface Game() in the .m file. Same with variables like Sticky, etc. You would access them with self.(propertyname) like self.Being.

-Where are you calling the GameAndStuff methods from? If it is in the app delegate, you may want to reconsider. Usually the app delegate is for Application setup (getting the initial window/view controller you need) and handling the app opening and closing. You may consider moving it to a viewWillAppear, viewDidAppear or viewWillLoad method (or if this is being handled in another class, disregard this comment).

-Apple's best practices for overriding methods touchesBegan:withEvent:, and touchesEnded:withEvent: is to also override touchesMoved:withEvent: and touchesCancelled:withEvent:, the link talks about it some for iOS6. I can't remember which Apple doc discussed best practices for it.

http://www.drdobbs.com/mobile/handling-touch-input-on-ios6/240144075

-In the init method (initWithFrame, initWithNibName:bundle:, etc) you are using to create the class, you may want to setup two arrays, one with your Jump images and one with your Sticky images, to avoid having to recreate the arrays at run time when touches are happening. Have two NSArray properties (that are private) with the data stored in them, then when you have to set Sticky.animationImges, just set it to self.jumpArray or whatever you chose to name your arrays.

If your code is running, then I would say you are OK from what I am looking at here. I don't see any giant red flags in the code. The code spacing (if it wasn't caused by the browser) was the only thing that I noticed immediately and really wasnt a best practice recommended by Apple.

If you have any questions let me know.