在看了almost.at网站之后,我找到了Cappuccino。
Cappuccino是一个很好的框架。有让我心动的UI层。很苹果。又能免去写
我决定看看这个用Objective-J的框架。
顺手译了一篇起步(意译):
原文:http://objective-j.org/learn/tutorials/objective-j-tutorial.php
Objective-J is a new programming language based on Objective-C. It is a superset of JavaScript, which means that any valid JavaScript code is also valid Objective-J code. Anyone familiar with JavaScript and object-oriented programming concepts, classical inheritance in particular, should have no difficulty learning Objective-J. Familiarity with Objective-C will be helpful, but it is not required.
Objective-J has two types of objects, native JavaScript objects and Objective-J objects. Native JS objects are exactly what they sound like, the objects native to JavaScript. Objective-J objects are a special type of native object added by Objective-J. These new objects are based on classes and classical inheritance, like C++ or Java, instead of the prototypal model.
In Objective-J, method names are split across all of the arguments to a method. These are not technically named arguments. The method above is named setJobTitle:company:. This is achieved by concatenating the first part of the method with all the subsequent labels, in order.
The parameters to a method must be passed in order, and all of the parameters are required. To call such a multiple parameter method, we pass our data after each label:
参数在传入时是有顺序的,并且都是要求的(没有默认参数这一说)。调用一个多参数的方法,可能是这样的:
[myPerson setJobTitle:"Founder" company:"280 North"];
As you can see, each colon is followed by the input that will be mapped to that parameter name. That sequence of label, colon, input is repeated for each parameter.
You may be wondering why it matters what the actual name of the method is. One pattern you'll find in Objective-J and Cappuccino is the idea of passing a method as an argument to another method. This is used commonly in delegation and in the event system. Since methods aren't first class objects in the same way as JavaScript, we use a special notation to refer to them, @selector. If I wanted to pass the previous method as an argument to another method, I would use the following code:
[fooObject setCallbackSelector:@selector(setJobTitle:company:)];