Special App Stores
Friday, May 8th, 2009Today I was having a conversation about the Apple App Store App Review process and I realized that I don't really mind a little bit of censorship but with a twist…
Today I was having a conversation about the Apple App Store App Review process and I realized that I don't really mind a little bit of censorship but with a twist…
This is by no means official. After lots of (repeated) googling I managed to gather this information. Feel free to add your Q & A or make corrections.
Hello Objective C (objc) from a (mainly) Java developer. I’d love to welcome you into my portfolio of programming languages but hey, what’s with that slang, that weird terminology?!
In this blog post I will try to provide you with a translation, a dictionary or an index of terms that are used by objc programmers. If I have the time I will even keep it up to date…
I hope I am not breaking any NDAs by posting this, I am sure I will be told if I do…
Let’s not waste any time and jump straight in:
| Java |
Objective C |
What the?! |
| - | id | Just remember: everything is an id. Any object, any … anything. |
| Class (concept) (defined by a class) .class Files use .java extension. |
Class (concept) (defined by an interface and an implementation, see class structure below) class method Interface files use the .h extension, implementation files use the .m extension. |
Wanna know the class? do a [myObject class] |
| Interface | Protocol Files use the .h extension. |
One adopts a protocol rather than implement an interface. |
| this, super | self, super | Easy. |
| null | nil | lol |
| Field | Property (and instance variable) | One declares an instance variable (optional), then declares the @Property and finally specifies how it is implemented (@synthesize, @dynamic). Easy as. |
| Call / Invoke myObject.init() |
Send Message [myObject init] or myObject.init() (quite unconventional though) |
That is how one uses a type’s methods. This gets more complicated, look up Selectors in the context of sending messages. |
| Subclass class A extends BaseClass |
Subclass, Category, Extension @implementation A : BaseClass (CategoryOMG ) |
You see, things are not as simply as you thought. A class can not only be extended but also When defining a category you must import the class’s interface file. |
| abstract | - | N/A |
| public, protected, private | same | After specifying @public (or another) you can just list all the instance variables that have the same visibility. No need to do it for each variable. Cool eh?
One mention goes to package which cares about how many bits your platform has. google for this (search box available above) |
| static method, non-static method static void doSmth(){} void printName(){} |
class method, instance method + (void) doSmth; - (void) printName; |
That is just the method declaration in the objc column. The implementation uses brackets after the method name to group the method’s code, just like Java. |
| public void setOrigin(int x, int y); | - (void) setX:(int)x andY:(int)y;
Default return type is id. |
AndY is just a label for the second argument. Note that the colons and the labels are part of the method name. |
| Object | NSObject | This isn’t necessarily the Class that everything extends from. There is also NSProxy and you can also write your own. Feeling brave already? |
| toString() | description | The NSObject implementation returns the name & address of the object. Sounds familiar? |
| import | #import | One can reference just the class not include the whole thing. See comment below. |
| Class structure: import java.lang.*; class MyClass extends BaseClass implements Comma,Separated,List,OfInterfaces { //method definitions |
A class requires an Interface and an Implementation.
#import “BaseClass.h” @interface MyClass : BaseClass <Protocol1, Protocol2> //method declarations //and then don’t forget the implementation #import “MyClass.h” @implementation MyClass |
Too much can be said and surely you will be asking me questions anyway.
Still: @Class is used when no instances are created / used in your implementation but rather parameter names are of that particular type. Is is simply a low-weight #import. |
| Interface
interface A extends AnotherInterface, YetAnotherInterface{ |
Protocol Specified using @Protocol @Protocol A <AnotherProtocol, YetAnotherProtocol> //required by default @optional @end |
So much better…
Can incorporate another protocol just like Interfaces can extend other interfaces.
Methods are @required (by default) or @optional. Use these to group the mandatory and the optional methods or your You can declare objects that adopt a protocol: And last, you can forward reference a protocol: |
| MyClass myObject = new MyClass(); | MyClass *myObject = [[MyClass alloc] init];
or for non static typing: |
These are virtually equivalent. I suggest you use static typing if you want your compiler to be able to tell you if some method does not exist in the type that you are using, for example. |
| object’s fields initialization { [...] } and for static fields /* Honestly, when did you last use this rather than a constructor with arguments? */ |
- init - initWithBlah - init… and for Class initialization + (void) initialize; |
NSObject’s init returns self. Therefore all classes should define an init method to initialize their instance variables.
The runtime will call initialize before using a class object. I am a little bit confused myself but I believe them. |
| java.lang java.util etc | NS, CG, CF | NS = NextStep CG = Core Graphics CF = Core Foundation unless I am wrong of course. |
| instanceof | Defined in NSObject:
isMemberOfClass – actual class |
Cool!
Responds to selector means that the method exists in the class passed as argument while conforms to protocol means that ALL the methods in the protocol. I suspect that a YES response is returned if the methods defined by the protocol exist in the type passed as argument even if the type does not conform to the protocol. |
| synchronized | @synchronized() | No synchronized keyword for methods. A mutex is required. Self is a possible candidate, another good one can be _cmd as long as the method name is unique. Who is _cmd? Google in the search box above. |
| Exception | NSException
@try; @catch; @finally and @throw are the keywords. |
You can throw other objects, not necessarily part of the NSException inheritance tree.
Once an exception is caught it can be re-thrown by using @throw without having to specify the argument. |
| !!!
Invoking non-existent methods. Say they have been deprecated and removed from the API. |
forwarding
- (void) forwardInvocation: (NSInvocation *) theInvocation { Here’s what just happened: a method that does not exist on our “self” was called and the runtime forwarded the call to the method I wrote above. It could’ve freaked out but it didn’t, it kept its calm and got my kudos. The original Note: the NSObject’s forwardInvocation doesn’t do much. Soz. |
This is so cool, it should be a mandatory feature in all modern programming languages.
Can replace @deprecated, multiple inheritance (I can almost hear your cry), surrogate objects, proxies, delegates and more. It is up to you to confuse the crap out of all those that try to steal your job. Piece of advice: consider overriding respondsToSelector, isKindOfClass, etc to make it look like your surrogate objects actually belong in the type hierarchy. That will simply make you irreplaceable. |
| Remoting | RPC | Remote Messaging
Type qualifiers: Example: |
Normally all these qualifiers are to be used in the protocol that defines the remote messaging, not in the classes that you implement. They are implementation guidelines more than anything.
New to pointers? Then trust me: out and inout only make sense for pointers. |
| @deprecated | @interface SadClass - sadmethod __attribute__((deprecated)); @end |
|
| Spring Framework, Log4j, Maven, Axis, Acegi | LOL, ROFL, ZOMG | I just thought it would be funny |
My conclusion: objc is too powerful for its own good. God have mercy of all those who end up stuck in teams that have bad developers. Just stop and imagine someone abusing Categories and Extensions, what a disaster that project can become. Let me know when that happens though, I may have the right medicine
Do you want to study objc in depth? Well if you have an apple dev account then you already know where to find it. Otherwise try this wikibook.
Cheers…
p.s. special thanks go to my surgeon (who is truly awesome btw) who provided me with the time and the painkillers required to read the objc documentation
On the iPhone 3G one can select Exchange under Email configuration.
I had everything I needed: server address, username, password, domain, you name it! Yet the connection could not be verified.
In my case the problem was that i was typing https:// before the exchange.company.com server address. Do not do this! I am running version 2.1 on my iPhone and if you put http or https in front of the server address then you are bound to fail to connect.
HTH!
Cheers…
Apple have just released (officially) Java SE 6 for your Leopard running Mac
More info: http://docs.info.apple.com/article.html?artnum=307403
Release notes:
This update provides Java SE 6 version 1.6.0_05.
This release does not change the default version of Java. This release is only for Mac OS X v10.5.2 and later, and should not be installed on earlier versions of Mac OS X. This release is for 64-bit Intel-based Macs only and cannot run on PowerPC-based or 32-bit Intel-based Macs.
Software developers can visit the Java Reference Library for information on this release’s features.
To download just go to: http://www.apple.com/downloads/macosx/apple/application_updates/javaformacosx105release1.html
Now should we also expect a Java ME release soon? I really doubt that will happen any time soon…
Cheers
There is one thing that often makes me close Safari and fire up Firefox: missing link highlighting.
The Register interviewed Eric Klein and asked him if Java lovers will get the goodie VM on the Apple platform. The response follows:
“We’re very excited,” Eric Klein, Sun’s vice president of Java marketing, told the The Reg. “We’ve spent the last 24 hours furiously looking through what information was made publicly available, and we feel comfortable enough at this point on the information we have to commit the engineering resources to bring the JVM over to the iPhone and the iTouch as fast as our schedules and Apple’s release schedule will allow. [...] We of course chose to set the price of the JVM at… free! Apple explicitly said developers can chose to put free applications through the App Store and – heck – we’re doing it! [...] We have a lot of learning to do, as do all the developers who just got access to the SDK. We just thought it was really important that our development community has the opportunity to write a Java app and have it run on the iPhone”
So bottom line:
- most likely it will be a JVM (unless they decide to restrict it to a KVM)
- FREE
- no info on JNLP
- no info on Safari Java plug-in
- no details on the level of integration with the underlying OS
It looks like we’ll just have to wait and see. But, to be honest with you, i think the iPhone JVM is going to be handy only for the “lazy” developers who won’t feel like learning how to use the Apple SDK.
Now will it be a KVM or a JVM… I guess we’ll find out in June or so
Cheers…
Hello again,
I just read in one of my feeds about Trism.
As I was watching I realized that Trism is built only for the iPhone and the iPod Touch. Why not the Wii???
This could be a really fun game. Think about it: two or more players, tilting and turning their Wiimotes trying to finish first!
Using A one could drag lines and by tilting the Wiimote they can achieve the same effect as when the iPhone would be titled.
Yup, that’s all. Nothing more. This could be the perfect Wii-ware kind of game.
What do you think?
Cheers…
Hi there,
If you want the contextual menu for an entry in your dock and you are really lazy then just Click and Hold the button down for a couple of seconds and the contextual menu will show up.
Did I mention that holding two fingers on the trackpad and clicking achieves the same effect? Who needs that Right Button anyway?
Cheers…