More Thoughts on Xcode…Getting the Hang of It – Updated 12/17/12!
Now that I’m getting into it with Xcode I’ve got more experience and a bit of knowledge – and a few gripes I guess.
Gripes…oh woe is me 🙂
- Numero uno – come on this syntax is a mess. Dots, spaces, braces, and brackets – this language has them all. It takes quite a while to get the hang of this deal, but it does start to sink in after a while although I’m not sure it makes sense. Reminds me of physical chemistry and differential calculus.
- GUI designer – while in some ways I can see the power of storyboards, it is also pretty obvious that there is room for improvement. For example why can’t I be zoomed out and still click on a control? For doing layout with an iPad app on a laptop – good luck. Also – the myriad of ctrl-click and drag actions are cool, but you better be using this tool all the time or you’ll never remember what do to. It also seems like things are buried so deep in places – like try to find the name of a control so that you can refer to it from code. Its in there, but…its not.
- GUI Designer – get used to looking in half a dozen places to figure what’s attached to what. Phew…it takes some getting used to – sounds like a broken record. Java tried this back in the day with mysterious wiring up of stuff and then not seeing it in code. Never liked it – will take some getting used to.
- The project structure is a mystery to me for what should go where and all that kind of thing – on th egood side is doesn’t seem to matter much either. Its also too bad that you cannot (in file explorer view) see the methods in a class. That’s a handy way to zip down to a spot – I realize you can do this in the symbol navigator, but I see spend most of my time in the project navigator.
- Content Hugging: 999 vs. 1000 is important to remember…don’t think to just use “required” or something…sigh.
Good Stuff – yes there is some:
- Xcode is so involved that it really forces you to design first and then code. To me this is a good thing, but it does make learning more difficult and they really should have a 3rd and 4th project in the “your XXX iOS App series”.
- I do like the GUI designer. Drag and dropping and the segues are cool and make sense. If only it were a little more obvious how to pass data around.
- Feedback from the GUI tools and positioning of controls is outstanding – best I’ve ever used, but forget doing iPad design even on the best MacBook – d’oh.
- On my machine Xcode is pretty zippy – keep in mind I have a KA machine. There is a certain elegance, but it will take quite a while to get used to it. One thing for sure is that I’m starting to like the keyboard on my laptop now that I’ve had to type a lot on it.
A few things in the middle:
- This is a pro/cons – the property getter/setter generation is nice, but not seeing the code is also difficult when learning and debugging. Perhaps a better solution is a display option to show/hide the getters/setters?
- If you started your project without a navigation controller, you can add one later. Just drag it out and make a segue from it to your first scene. Then select the navigation controller view and click the attributes inspector. Be sure to check “Is Initial View Controller” and make sure this is not selected on the former original view.
- Communications between the IB stuff and code should be better documented in the “your first xxx” tutorials. Basically if you really need to get used to the connections, delegates, and how those things work. For example if you want to handle form validation you need your view to implement the correct delegate, then make sure each form field has the view set as a delegate (the one that is handling the validation), and then if you have a button to enable/disable make sure you have CTRL-dragged it to the view and connect it to the correct button item in your code. It works, but lots of steps that aren’t always clear.
All that being said I Think the next thing is to gather up all the comments and put together a “don’t forget these things” post like I did with PHP, Python, etc. Will save me heartache down the road I’m sure.
Some handy things to remember:
- In strings use %@ for string parameters and %u for integers. I always forget those.
- Arrays are zeroth order
- withCompletionBlock – learn to love it 🙂
- It is worth spending a lot of time passing data back and forth between views and testing how views load with viewIllLoad, viewDidLoad, etc.
- Many shared libraries were created prior to ARC – if you want to use these with an ARC project you need to mark the files with a compiler flag in Xcode “-fno-objc-arc”.
- -ObjC is another commonly used linker option in Xcode. This option is required when linking to static libraries written in C/C++. It forces the compiler and linker to use full sets of symbols.
- When building for iPAD you need a few decent icons – at least two. 72×72 px. and 144x144px. at a minimum.
I have to admit that a couple of days ago I was really worried and upset. I couldn’t get things to work. I took an hour off, ran 4 miles, had a beer, and played a bit of Borderlands 2 with Dior. I came back and something clicked in me and I started to have success. Its a good lesson when you get frustrated – take a break and relax, then come back and read again. Breathe deep – and focus. I’ve learned that from karate. It works.