Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert nib/xib to objective C code?

I am just wondering is there a way to convert nib/xib file to ojbective C code? I just want to find the equivalent code to the nib/xib file (I've tried nib2objc, seems the result is not what I am after).

Actually I want to compile this example

http://developer.apple.com/iphone/library/samplecode/TableSearch/index.html

without nib/xib file (I want it exactly the same with original), any idea about doing this?

like image 946
Mickey Shine Avatar asked Nov 30 '22 06:11

Mickey Shine


2 Answers

Check out nib2objc:

nib2objc converts NIB files (or XIB ones) into Objective-C code, including all the properties of each instance, the documented constructor calls, and also the view hierarchy.

nib2objc yourfile.xib > code.m
like image 93
Michael Avatar answered Dec 21 '22 07:12

Michael


In the general case, I think the answer is no. Nibs are not code; they're archives of serialized objects. So what you're asking is, "Given a graph of arbitrary serialized objects, can I generate some source code that might create such a graph without using serialization?" Without special support for such a process in all classes involved, I don't see how you could.

It would probably be more beneficial to ask about what you actually need to accomplish rather than this specific way of doing whatever it is.

like image 44
Chuck Avatar answered Dec 21 '22 05:12

Chuck