I Os Tips
Easy to apply tips that can improve your development workflow.
Know available tools and how to use them.
I believe you should use best tool for the job, and there are lots of tools that are perfect for specific tasks. This is blog post about tools I use
Write and use code snippets.
We often write similar code, stuff like dispatch to main thread, dispatch after, KVO etc. Use code snippets for that, this can save you lots of keystrokes and time.
Some of my most used ones would be:
- properties declarations
- dispatch_after usage
I’ve asked others on twitter:
iOS devs: What are your most used code snippets?— Krzysztof Zabłocki (@merowing_) February 18, 2014
Just be careful not to break DRY principle.
Read clang/gcc documentation to explore some interesting possibilities
- Vector extensions and component swizzle, useful when doing lots of math.
1 2 3 4
- C Function overloading to simplify code, instead of calling fabsf, fabsf you could have (Obviously that’s more interesting for your functions)
1 2 3 4 5 6 7 8 9
- require_super, useful whenever you are creating base classes and want to make sure your subclasses actually remember to call super.
using braces to have implicit return (last references value is returned, same as in ruby). I’m using this in KZPropertyMapper for a neat trick that allows me to execute some arbitrary code and still control returned value
attribute((constructor)) can be used on C functions for similar behaviour to +(void)load;
1 2 3 4 5 6
Use build phases, scripting and automation for your projects
Add this build-phase script AFTER compilation and you will turn all TODO/HACKS etc into warnings (but still be able to use treat warnings as errors)
Never again have someone test wrong version of your application.
You can use either very simple script like this one:
1 2 3
Great tool for seeing how tangled is your (or vendor’s) code, useful for refactoring or checking if agency that just send you some code knows anything about quality coding.
Use smarter breakpoints
Avoid temporarly modifying code
Instead you can call NSLog from breakpoints and continue execution.
User space breakpoints
By promoting breakpoints to user space you can have breakpoints that exist only on your machine.
Fast jump to feature you are working on
By combining above 2 ideas you can execute arbitrary code eg. to enable some feature without modifying code, and you can promote it to user space so only you get that behaviour.
More to come
There is way more tips we could mention, but let’s leave something for future blog posts. If you have any questions or suggestions send me a tweet