Best iOS hacks from Twitter: March & April Edition
I love spring.
Everything is blooming in Kyiv and city is just magically beautiful. Probably good Kyiv weather somehow affected global iOS community 😍.
So, in March & April I have bookmarked dozens of great tweets — debugging tips, cool tricks to structure code, smart ways of using extensions, custom operators & singletons and lots of funny jokes on how slow is Xcode (as you would normally find on Twitter).
I also noticed how many wise thoughts were shared in my feed. So I added a new section with serious thoughts about our industry. Hope, you will like it and let’s jump in!
Twitter tip #1
An interesting “feature” of UserDefaults, which is storing all arguments that were passed to the application during the launch. What a great thing for debugging! Not just for Command Line scripts but for iOS applications as well. Loved this gem:
Twitter tip #2
Are you struggling with debugging crashes caused by infinite layout? With this handy flag, you can set a layout loop threshold and quickly define an issue. Works with UIKit and AppKit! Take a look:
Twitter tip #3
In March Peter Steinberger made an interesting talk on smart debugging (check slides). And Kristina Fox summarised some of Peter’s tips on dealing with different debugging use cases, using tools and highlighted the best slides. Take a look if you missed this talk:
Twitter tip #4
Need to debug how your UI would adopt if the text would be twice as long? Surely, “there is a flag for that” —
Twitter tip #5
One more debugging tip for you. So, if you have a document-based application these two properties could save you some time during debugging.
Twitter tip #6
Interesting thread here. As Loïc Lecrenier pointed out, you might consider using your own custom geometry types (if your application requires so). Indeed, there could be plenty of benefits for you:
Twitter tip #7
This simple yet useful extension will help you shuffle arrays easily and without a hustle.
Twitter tip #8
Get immediate 100x productivity boost with this little tip! Use Xcode Quick Open dialog to open an exact line of the specific source file. Neat!
Twitter tip #9
Did you know that you can save indent preferences in Xcode panel as project-wide? Super useful when you have different indent setup with the project you’re working on.
Twitter tip #10
There is a hidden Xcode property that allows you to use multiple cursors simultaneously! Just like in Sublime Text. That’s a pure gem and thank Daniel for sharing.
Twitter tip #11
Breakpoint management is Xcode is really powerful. But have you noticed that you can also set automatic breakpoint on tests failing? So you’d able to inspect variables state and define a problem right away.
Twitter tip #12
Not everyone knows that it’s possible to set up custom hotkeys in Xcode for some actions you use frequently. You’re welcome!
Twitter tip #13
We have already seen some ways to measure build time and show label right in Xcode status bar. This little script will print build time right inside the console.
Twitter tip #14
You can cancel touches on you UIButton inside UIScrollView by overriding this handy little property:
Twitter tip #15
A nice way of using extensions as an access management wrapper for your methods/properties/etc. of the class.
Twitter tip #16
Extensions are a truly powerful tool to better structure your code. Here comes nice example of using extensions with structures and their initializers.
Twitter tip #17
I think, we mention similar tip in the winter Twitter tips edition. However, it’s a good reminder that unbounded ranges could be a great option to classify different kind of information in a simple way.
Twitter tip #18
Inline computer variables/functions/classes could be extremely powerful in some cases. But surely it’s a question of balance. You don’t want to get trapped into infinite inception, don’t you?
Twitter tip #19
Embrace the full potential and power of custom operators. This little operator allows you to assign a value to a variable only when this value is valid. Simple yet powerful trick.
Twitter tip #20
This custom operator definitely looks interesting. But it’s worth mentioning that you probably shouldn’t overuse custom operators in Swift. Overwise your codebase become super weird for the colleagues. After all, we’re writing code for humans not for computers. Just keep in mind.
Twitter tip #21
This nice code snippet would help you detect when the user stops typing in the text field without timer-related pain:
Twitter tip #22
Some cool nesting tricks. Did you know that you can override a method and put a different return type there if it’s a child of original return type?
Twitter tip #23
Nested types inside types with generics would automatically inherit parent’s generic types (Sorry for my English with so many repetitive words, I really tried my best). Anyway, what a tremendous “feature” for better code structuring.
Twitter tip #24
Whether singleton is a good or bad is a kind of a long debate. Nevertheless, this trick would help you use singleton in a more pleasant and understandable way.
Twitter tip #25
This little snippet will allow your codebase to keep supporting pre Swift 4.1 versions without unnecessary warnings.
Twitter tip #26
We all know how important accessibility is. And it’s our responsibility to build apps with accessibility in mind. So Xcode Accessibility Inspector would help you test different kinds of properties and make sure your app adopts to them properly.
Twitter tip #27
If you’re using Result pattern for JSON error handling, for example, you should definitely consider making your Result type conditionally Codable:
Twitter tip #28
I loved this design thread on the way how we see complex objects with many elements. These tweets attempt to describe how people perceive visual elements when certain conditions apply (the Gestalt principles). Curious information for those of you who deal with design.
🙈 Twitter fun
When your iOS app release is tomorrow…
No, no, it’s not about your project :)
I will leave it here as an excellent tip to use:
😍 This is such an adorable little QA engineer:
And more funny moments to make you smile (or think):
🤔 Some serious things
- We have a lot of great apps, tools, and resources made by the community. All those gems are open-source and free, which is great! However, that set up the same expectations for other software. Somehow people think all apps should be free and developers don’t deserve to be paid. It’s wrong and I feel very upset when someone asks Flawless App for free. The same things happen over and over in our community:
- At the same time, making business from your app is super interesting! You can be just a solo iOS developer and keep releasing successful products. Remember: being indie & small is an advantage:
- This tweet reminds me of a lean approach when you step-by-step make & iterate achievable things:
- We all know that EU General Data Protection Regulation comes into force on 25 May. So that will definitely change things and the way of how some people think about personal data. We as developers deal with users data a lot, so maybe we have to ask ourselves these questions too:
- Being a senior developer is …
- Being “a good networked” is hard. When you deal all days with your project, you sometimes forget how to deal with people… These tips can help to make communications with other humans easier 😅
- Nice note on making things easier for OSS newcomers:
💗 P.S.: Maybe you know that we made Flawless App — tool to match your design with the final iOS app. If you have some time to support us, please give us your honest feedback. The more feedback we get, the more we can improve Flawless App. Thanks 💗