Tuesday, December 1, 2015

iPad Pro and Apple

Last Sunday, I got to try iPad pro with all its accessories (most of the outlet here has only iPad pro without keyboard & pencil).

I am slowly converting to anti-apple over last few years; to be precise post Jobs & iOS 7 which started pattern of releasing untested software in the wild. So I am here to just log my thoughts/rants on the mistakes Apple made with respective to this product.

I believe they clearly lack the leader with laser sharp focus. Apple Watch, iPad pro and Cars* are examples of following Microsoft in its peak to going after every business they can think of, because "we have lot of money than we ever dreamed of". Before you say anything about Apple TV, it is not a new product. It's a delayed one from Steve's era.

Back to iPad pro. For the record, I am not against the size or stylus . I find it could have been done with iPad (all sizes). Just like iPhone ridiculous 6+ decision (image stabilisation feature in a wrong sized iPhone), this is a wrong sized stylus friendly iPad.

iPad Pro

  • Too big
  • Home screen layout, not updated for new device. (Apple: No need to engage with iOS dev's for the new secret device)
  • Though I knew about side-by-side apps, I find the swipe from top of second app to switch between apps is stupid UX. Apple, please revisit UX before you get going with a Duct tape solutions.

Keyboard


  • Cool, but I find it definitely missing iOS specific keys that Logitech has. Seriously, you built a first-party keyboard without the function row of your existing mac keyboard design? But I like the feel of the keys but not the travel.
  • No Caps lock indicator
  • No Escape key
  • No keys for Brightness adjustment
  • No keys to adjust Volume
  • No dedicated keys for Home or Search (I know CMD+Space works, but iOS is not for mac users you know)
  • Bluetooth pair/un-pair?
  • In default Notes apps, I found that CMD+Arrow (left/right) doesn't behave as expected. Could it be NSTextview vs UITextview?
  • And I have noticed, the screen didn't turn off when I close the cover, at-least once in my total of 3 tries.
  • And finally, I find it hard to stomach the asymmetrical top surface of case cover.




Volume/Brightness, is something people might not use much. Did you think could be because of its current no. of steps, which is hidden three level deep?

Pencil

  • The only update to iOS software to support the new hardware. 
  • However I am not happy with the feel of it. 1. Too much glossy, rounded finish is not helping in nice grip 2. The upper body of the pencil weigh heavier than the bottom, so I didn't find it pleasant compared to any old school pencil.
  • And it didn't work in pre installed DocuSign. I was expecting it to work everywhere regardless of app updates. 
It is not an iPad for me. What I want is Surface Book pro style Macbook pro i.e., Run OSX & iOS based on the mode I choose. We don't want to carry 5 different device and constant charging, world is a better place if we limit to few.

Apple, for god sake work on better & greener battery technology. And please hire lot of QA and release once when it is ready. Release something every quarter for investors sake is not going to help anyone.

Saturday, February 21, 2015

Swift/Objective-C Interoperability - Behind the "Configure Bridging Header" dialog

Disclaimer: Yes, I know about the typo "briding" in screenshots, but I'm lazy to redo all, so please ignore and read the article in peace :-)

Apple officially supports mix-and-matching Obj-C and Swift code in same xcode project.

When you create a first ObjC in a Swift project or vice versa. Xcode ask your permission to create a special file called Bridging Header.

If you say Yes, xcode silently creates a new header file named YourProjectName-Bridging-Header.h and add to your project. If you observe it also modifies your project (.pbxproj) file.

From the diff, you can see that it adds three configurations

  1. Enable Clang Module,
  2. Swift Obj Briding Header and
  3. Swift Optimization Level.

How to add the Bridging Header file manually?

You can say No to xcode dialog for adding bridging file and still add the file manually.

Bridging Filename should follow the same convension used by xcode?

The answer is No.

While searching answer for this question I found that the bridging file has to be added to your project's main group not under any other group.

Eg., I try to add bridge.h to subgroup and got the error.

bridging header '/Users/palaniraja/Desktop/Data/MyWorkSpace/try/swiftbriding/bridge.h' does not exist

Well, I was wrong. If you add it to a different group you need to provide the correct path. For instance, in this case it has to be swiftbriding/bridge.h

Remember the three configurations added by xcode? when you set the Objective-C Bridging Header it add the other two (Enable module and Optimization level) without any additional steps.

Common Errors

  1. "... bridging header 'path_to/project/bridge.h' does not exist"

    Please check whether your bridge file is available and in correct path (typo is the number one culprit)

  2. "... error: use of unresolved identifier 'ClassName'"

    Check whether you had included the ObjC class you use is added/imported in your bridge.h file.

What is happening in build process?

Here is the screenshot of build steps with bridging and without bridging.

I've noticied that it failed when compiling the .m file which uses the swift object. So I was curious to see whether the CompileC is passing any additional argument when you provide a bridging file. To my surprise, the compilec is identical for both.

I believe, the Compile Swift source files step does the necessary magic by linking/exposing the swift files to objc.

Is there any difference in adding bridge file to a ObjC project / Swift project?

No

I have noticed only the project name is the only variable in this dialog.

How to use ObjC classes in Swift project?

  1. Setup the Bridging Header properly
  2. Import all your ObjC class headers in your bridge-header.h file

How to use Swift classes in ObjC project?

  1. Setup the Bridging Header properly. Yes it is required for Swift to ObjC as well
  2. Import the yourprojectname-swift.h in your ObjC file where you need to refer the swift classes.
  3. You do not have to create yourprojectname-swift.h file, the compiler will be creating the same in build phase.


Sunday, February 15, 2015

Image Slicing (Repeatable image) with Xcode Asset Catalog

Image slicing option in xcode asset catalog allows you to define resiziable area an image so it can be repeated to fit the object's height & width.
The same can be achieved with resizableImageWithCapInsets:UIEdgeInsetsMake but I always messup the arguments and usually we have to try a random number by measure the edges with image editor (eg., preview) [[UIImage imageNamed:@"image.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(bottom, top, left, right)];

output


Why

Deleted code is debugged code
  • One less line to maintain/debug
  • No need to create an IBOutlet to set image
  • You can refer the image in IB and preview right away.
  • For all states (in case of a button)

What is the Catch?

  • I don't know how to reset (inset) from xcode asset catalog itself.
  • Editing in UI again if you change the image is little cumbersome at times. (usually when you try to switch between horizontal/vertical/both)
You can still manually fine tune the inset arguments in code if required. (Right click on an image Show in Finder edit resizing object in Contents.json refer the screenshot)

There are three ways you could resize the image to fit your need.

  • Horizontal (3-part horizontal)
  • Vertical (3-part vertical)
  • Both (9-part)



For the first two options, it let you select non-repeatable left edge, resizable middle area, and repeatable right edge.

Horizontal slicing is best option if you have the asset that fit the height of your button/host view. If your host view (button in our case) match the width of the asset then you can do the same with vertical slicing.
If you want to truly want to repeat the image to fit dynamic size (width x height) then 9-part is the best option.

Slicing



Behind the scene



Step by Step





Links:

Sunday, January 18, 2015

Book recommendation : Creativity Inc by Ed Catmull

It is no surprise that you know about Pixar if you are even remotely knew Steve Jobs and his history. And you definitely heard about Pixar’s movies Toy story,  Finding Nemo, Wall-E, Upmore.

 Amazon link


Ed Catmull, co-founder and president of Pixar compiled his learnings; from failure to success. This book differs from many of the other books because of his honesty. He not only documented his success stories, he also documented their failures.

And he unveils more interesting stories about the pixar internals and interesting stories about our favourite con man Steve Jobs.

I highly recommend the book for everyone. It also assumes that you watched most of the above listed movies to fathom some of the stories told in the book.

If you are the one who do not have time to read this book/listen to audio book, at least watch shorter version of the book from his talk.


Few of my kindle highlights from this book:

We had learned long ago that while everyone appreciates cash bonuses, they value something else almost as much: being looked in the eye by someone they respect and told, “Thank you.”

- I did suggest the same around 2010 to a friend to run his company

Steve put his arms around us and began to cry, tears of pride and relief—and, frankly, love.

- Steve after Disney merger

I've also learnt that he is also affected by Ego's speech as much as I do. And I'm planning to reread the book after couple of years. There are a lot of lessons to learn from this book.

Links:

  1. Podcast: The Incomparable panel's discussion about the book 
  2. Catmull Talk: Youtube
  3. Amazon Link: Creativity Inc
  4. Ego's speech from Ratatouille
  5. One of my favorite scene from Toy story 2 - Fixing Woody