Crossing the Return Threshold

Mobile Makers Week 8 — T minus 1: The Day Before Graduation

Robert Figueras
my iOS Dev Journal

--

This is it. The last week of Mobile Makers. Tomorrow is the big day. We’ve been (pretty much) working non-stop for the past week, putting in full 10/12/14 hour days last weekend.

I wish there was more time and, yet at the same time, I wish it would just be done. Exhilarating and exhausting. Frustrating and incredibly elating. I believe I’m crossing the return.

Our app is coming along very well and we have been really clicking the last couple days. Yesterday and the day before were a great days, great communication and back on track full steam. We were really working as a team and when it’s clicking, we’re having fun. When it’s fun, we’re clicking even more. We’re getting the final polish on the UI elements and tidying up the functionality pieces.

One of our breakthroughs was figuring out a very timely “optimization” (at least that was really the effect). It was just the idea of refreshing a cell’s contents with data from an asynchronous call, but within the cellForRowAtIndexPath tableview delegate method. We were trying to load a tableview with images that were being called from separate asynchronous URLs; however, the cell data was being populated without the images until you scrolled through all the images. This meant that images were being assigned to the cells, but they weren’t showing up until a dequeued cell was reused. We were just about to apply a somewhat detailed solution to try to remedy this until we finally realized the answer.

Calling [cell setNeedsLayout] refreshes the cell and causes the images to get reloaded. This tiny two word method call saved us from going down the wrong path.

There is so much that we have been learning at a very fast pace this last week, its been hard to capture all of it (a great idea for another app I plan on pursuing later). So here are some things I learned in the last couple days:

  • PromiseKit by Max Howell is ridiculously powerful in simplifying and modularizing asynchronous calls. We ran into core issue when trying to gather related data from Parse. We had something like 6 nested asynchronous calls. PromiseKit would have probably would reduce it from 100s of lines to about 20 lines and it would be 100x more effective, efficient and modifiable. If we have the time afterwards, I would love to refactor our app using PromiseKit.
  • The MultipeerConnectivity framework is an iOS 7 framework for connecting to nearby peers over Bluetooth, Wi-Fi, or P2P, without distinction between the transport layer being used. I think that Multi-peer connectivity seems to work in concurrency, meaning, it is inherently on a thread other than the main thread. Using Grand Central Dispatch (GCD), changes that would be applied to the UI need to be on the main thread. So if there is a latency in updating the UI from a block returned from multi-peer connectivity status, try placing the UI-updating code within a queue on the main thread.
  • Nesting asynchronous calls can actually make performance slower. When trying to query data in a relation from Parse, usually nested queries are needed. This seems to be somewhat slow from a performance standpoint and perhaps PromiseKit might alleviate it. However, it gets even more latent when an asynchronous call is nested within an asynchronous call. It seems to increase the lag by 20x.
  • Fixed a logic bug with when trying to disable user interaction of the top View Controller while using the SWRevealViewController. There is a delegate method of the SWRevealViewController that gets called every time the views slide. So placing a boolean toggle to flag when the view has slid open and when it has slid closed allow the proper application of setEnabled to the top view controller’s views.
  • Finally, when helping another student figure out scrollviews, I was able to research (and re-remember) that iOS 7 has a funny problem with autolayout. It can be frustrating not being able to get a simple scrollview ,with only 4-5 steps, to work. The scrollview doesn’t actually scroll when all the delegates, outlets from storyboard and setting the content size of the scrollview is set, if you are using autolayout. You have to call setContentSize within the method call —(void) viewDidLayoutSubviews { }. Hooray!
  • Learned how to get gravatars in an asynchronous call based on a users email.
  • etc ☺

Back to the grind. One last day and one last push. T minus 1.

--

--

Robert Figueras
my iOS Dev Journal

in order of importance: Papa, Hubby, Son, Sib, iOS Developer, Software Consultant, Musician, Entrepreneur Wannabe