Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MapSwift - lesson 13

leveton
March 07, 2018
48

MapSwift - lesson 13

leveton

March 07, 2018
Tweet

Transcript

  1. Profiling hotspots with Instruments Let’s look at one of my

    favorite features in Instruments - Color Blended Layers *Color blended layers only works with a device. 1. Hold down the play button and choose ‘profile’ 2. Instruments will launch, choose Core Animation 3. On the right-hand side panel, choose ‘Display Settings’ 4. Check ‘color blended layers’ The phone should now look like a limited heat map...
  2. Profiling hotspots with Instruments Views in green are opaque views

    that are not blended. Views in red are blended views where the graphics processor blends the view’s CALayer. Here, we see that our main labels and sub labels are opaque while the label property of our detail and delete buttons are blended.
  3. Profiling hotspots with Instruments In MSTableViewCell, find the initializer methods

    for our two buttons and walk the property path setting the button label’s opaque property to YES. The button’s color will now be black unless you set it so do that too. Profile the App’s Core Graphics processing one more time:
  4. Profiling hotspots with Instruments With opaque button labels, the GPU

    is having to do much less work. If this table were to have enough rows where scrolling reached 60 frames per second, changing the opacity of the buttons could really benefit our app’s performance.
  5. Instruments Graphics profiling is just one of dozens of ways

    you can use Instruments to improve your app.
  6. NSLocalizedString and basic localization Notice throughout our app that any

    strings to display (not strings used as identifiers) have been wrapped in an NSLocalizedString() function. The operating system will match the argument passed in with a key that you must provide. The keys are located in a .strings file that you must create. There is a .strings file for each language supported by the operating system.
  7. NSLocalizedString and basic localization Apple recommends that all apps, even

    those from solo developers, support English, Spanish, German, French, Portuguese, and Italian. These languages cover the majority of iOS users using the Latin alphabet. Localizing Asian languages is much more difficult from both a translation and user interface standpoint and, for independent devs, may not be feasible.
  8. Breakpoints, debug and terminal window XCode’s debugger offers the typical

    ‘step in’ and ‘step over’ functionality seen in the CS50 IDE. Besides the standard features, you can: • Create a breakpoint to make a sound when it’s triggered. • Create a breakpoint to send an email when it’s triggered. • Create a breakpoint to be ignored unless a variable is true or method returns true.
  9. Extensions Notice we implemented verticallyCenteredFrameForChildFrame: in more than one class?

    We could put the method in a global constants file but that’s overkill for large projects that are only going to use the method for a few UIView subclasses.
  10. Extensions Here are extend good old UIView so that any

    class that imports UIView+MSAdditions.h can call verticallyCenteredFrameForChildFrame: on any UIView or UIView subclass.
  11. Testing with XCTest iOS developers traditionally don’t test as often

    as web or server-side devs mainly because the front end compiler does static analysis - those red build time errors and yellow warnings. However it’s time to put to bed these two antiquated excuses: One screen size - now we have several. No legacy code - I can’t even remember 2007, can you? Gigantic, aging iOS codebases are now a thing.
  12. Testing with XCTest Looking in MapStackTests.m we have to setUp

    and tearDown methods. Think of this as init and dealloc in C - allowing you to use the same property in multiple tests.
  13. Testing with XCTest Our first two tests simply check for

    the correct input and the correct data type. Our third test contains one of XCTest’s best features measureBlock:
  14. Static and dynamic libraries .dylib (dynamic library) - linked at

    runtime and therefore may change and be recompiled. .a (static library) - linked at compile time and therefore doesn’t change during the runtime because the object code that makes up the binary is set.
  15. Frameworks .framework - combo of static and dynamic libraries along

    with header files and documentation. Useful when you have a suite of apps under one banner. For Google for example, the Gmail app, the Docs app, the Google Maps app, etc. all probably share a framework.
  16. Apple’s Human Interface Guidelines The HIG is the culmination of

    years of Apple studying user interaction and user experience and making it the highest priority. Notice that MapStack uses Apple default controls whenever possible i.e. no third parties and few custom objects. Before reinventing the wheel or linking a 3rd party library, you should dig a little to discover the amazing controls available to you at project creation.
  17. Apple’s Human Interface Guidelines Notice also that our map, rows,

    buttons, etc are well sized. In fact, many views have a minimum size parameter that cannot be overridden without some serious hacks.
  18. Charles - Intercepts HTTP traffic between your device and your

    webservice. Great for debugging web traffic. Paw - Build your http requests with different environments, auth tokens, etc. Sketch - Adobe Illustrator replacement that’s geared toward Apple devs, costs about an order of magnitude less with an even smaller memory and storage footprint. Paintcode - Generates code for the shapes you draw on their GUI canvas. Bezier path heaven. 3rd party tools
  19. Generics What if instead of having duplicate code bodies, we

    could simply have one code body and pass in a type as a parameter?