Tag: Cocoa

A Comment on Remote View Controllers in iOS 6

Ole Begemann has written an blog on Remote View Controllers in iOS 6, which shows Apple has adopted XPC in the sharing service of iOS 6.

As the XPC in iOS is still a private feature, we still have no idea about what will come together with the next major release. At he end of the blog, Ole put some outlooks regarding on XPC in iOS.

Remote view controllers are an exciting new feature for iOS. I sincerely hope that Apple will use this technology in iOS 7 to enhance data sharing and communication between third-party apps without compromising the iOS security model. We need it.

How could this work? Apple could ask developers who want to provide a sharing UI to other apps to include a second executable in their app bundle. This executable would be an XPC service that looks a lot like the MailCompositionService.app we analyzed above. Its main component would be a stand-alone view controller that was able to communicate via XPC and implemented some standard Apple-defined protocols named something like UISharingRemoteHost and UISharingRemoteService.

Apple’s existing UIActivityViewController would then maintain a list of registered sharing services and present these options to the user.

I hope we will see something like this next year.

With the 5-year evolution, iOS has been so powerful than ever before, unfortunately, it still doesn’t support inter-app communication. I think most developer would be very happy to see this being available in iOS.

As my consideration, I agree that the implementation described above is feasible, however, I doubt whether Apple will do this or not.

  1. Technically, XPC is introduced to OS X to help developers break a large App into several building blocks based on their functions. In OS X, the XPC services are privately bundled in their host App. Which means those services are not system-wide (A system-wide service module is something like Microsoft’s COM+), and there is still no way to invoke these services across different Apps.

    Although the XPC services are clearly different to the services on OS X, I believe that Apple will make a few XPC services be able to be invoked by other Apps (probably by wrapping those services into a common framework), but they would not allow any 3rd-party provider to create their own system-wide XPC services. Because it will be very difficult to handle the consistency of the services, especially on a mobile device. What if a service is not upgraded to the latest version? What if there are multiple dependency to different versions of a certain service? It will bring mess as well as benefit.
     
  2. As to the business strategy, Apple is always choosing the partner with great care. Those services which has integrated into the iOS not only benefit the users but also the service provider and of course Apple as well. So, what will make Apple allow any 3rd-party provider to provide system-wide services? I’ve no idea yet.

Anyway, let’s see what we will have in iOS 7.

用Key-Value Observing解耦视图控制器

Implementation with KVO

Follow 在Objective-C中,有一种称为Key-Value Coding(KVC)的机制。简单地讲,就是一组为对象属性命名的规则。符合这个规则的对象,可以使用runtime提供的-valueForKeyPath:和-setValueForKeyPath:方法进行访问。类似Java中的Ja...

Read More.

关于Core Animation工具箱的构想

最近在构思一个用于Mac/iOS开发的工具。感觉比较庞大,脑子里的东西比较混乱,决定先把最初的设想写下来,然后再一步步细化。

问题的由来

这个构思的起因是2011年底前的一个iOS项目。设计MM为了吸引用户,在UI中设计了各种可爱的元素。也差不多在这同时,Path 2登场了。其精致的动画让设计MM意识到动画也是体现UI表现力的重要手段。于是,她就开始设计中增加动画元素。

围绕这这些动画效果,我发现在设计和开发过程中有不少问题:

  • UI设计师如何描述动画
    动画与传统的静态UI不同,单单凭借静态的设计是很难把问题说清楚的。如果采用关键帧的方式去绘制一些分镜头的脚本,会给设计师增加不少工作压力。
  • 开发人员如何实现动画
    在Mac/iOS平台上,实现动画主要靠的是Core Animation框架。然而Core Animation比较底层,因此Apple对其进行了封装,提供了Cocoa Animation以方便开发人员实现动画。但不论在Mac还是iOS上,通过编程方式实现动画效果依然需要大量的代码,而且对于比较复杂的动画,开发人员还是需要直接通过Core Animation操纵CALayer、CAAnimation来实现。在我的项目中,最重的view controller里,居然有80%的代码用于实现动画效果。

于是我意识到,这样的开发是有问题的。理由很简单,设计师所设计的是动画,既然是动画,就不应该是几个分镜,几个关键帧这样的半成品。更不应该等到开发人员将代码写出来,再就具体的效果进行讨论。而开发人员也不应该堆砌大量的代码用于动画,因为同时具有艺术感和代码实现能力的开发人员真的非常少。想要做出高质量的动画,这样的过程没有几个回合是搞不定的。总之一句话:

Does real animator write codes? Definitely NOT!

在设计师和开发人员之间必须有个工具扮演桥梁的角色。类似于Flash上的工作流,设计师能够通过该工具直接做出大部分动画效果,而开发人员则在项目中导入这些预先定义好的动画脚本,并根据需要进行一些优化和微调。

如果存在这样的工具,不仅能有效简化设计师和程序员之间的沟通过程,实现工作职责的更合理分配。更重要的是,它还能使代码变得干净,提升代码和动画的可复用性。 Read More.