Automatically convert the XIB file to the objective-C source code file

Source: Internet
Author: User

From: http://www.yifeiyang.net/iphone-development-techniques-of-the-tools-for-chapter-1-the-xib-file-is-converted-to-objective-c-source-code/

 

Nib2objc is a small conversion tool that can automatically convert XIB files to objective-CSource codeFile.

Generally, consideringProgramXIB is directly converted to the sourceCodeFile. In this way, the connection between the instance variables and the behavior methods set through interface builder is also absent, and you need to hand over the code. However, the source code of the tool is public and can be done with slight modification.

When using the tool, first download the project code and compile it with xcode. a command line program file nib2objc is generated. Then execute the conversion as follows:

$ Nib2objc webview. XIB> webview. m

For example, the following code is output after the view is converted:

Uibarbuttonitem * view39 = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem: Specify target: Nil action: Nil]; view39.frame = cgrectmake (0.0, 0.0, 0.0, 0.0); view39.enabled = yes; view39.style = regular; view39.tag = 0; view39.width = 0.000; uibarbuttonitem * view64 = [[uibarbuttonitem alloc] failed: Invalid target: Nil action: Nil]; view64.frame = cgrectmake (0.0, 0.0, 0.0, 0.0); view64.enabled = yes; view64.style = disabled; view64.tag = 0; view64.width = 0.000; uibarbuttonitem * view57 = [[uibarbuttonitem alloc] failed: alert target: Nil action: nil]; view57.frame = cgrectmake (0.0, 0.0, 0.0, 0.0); view57.enabled = yes; view57.style = uibarbuttonitemstyleplain; view57.tag = 0; view57.width = 0.000; uibarbuttonitem * view33 = [[uibarbuttonitem alloc] initwithtitle :( null) style: uibarbuttonitemstyleplain target: Nil action: Nil]; view33.frame = cgrectmake (0.0, 0.0, 0.0, 0.0 ); view33.enabled = yes; view33.image = nil; view33.style = success; view33.tag = 0; view33.width = 0.000; optional * view66 = [[uibarbuttonitem alloc] failed: Failed target: Nil action: Nil]; view66.frame = cgrectmake (0.0, 0.0, 0.0, 0.0); view66.enabled = yes; view66.style = disabled; view66.tag = 0; view66.width = 0.000; uiwebview * view31 = [uiwebview alloc] initwithframe: cgrectmake (0.0, 0.0, 320.0, 460.0)]; view31.frame = cgrectmake (0.0, 0.0, 320.0, 460.0); view31.alpha = 1.000; view31.autoresizingmask = bytes | uiviewautoresizingflexibleheight; view31.backgroundcolor = [uicolor colorwithwhite: 1.000 ALPHA: 1.000]; audience = yes; view31.contentmode = audience; audience = no; view31.hidden = no; audience = yes; view31.opaque = yes; audience = yes; view31.tag = 0; view31.userinteractionenabled = yes; uibarbuttonitem * view56 = [[uibarbuttonitem alloc] Audience: Custom target: Nil action: Nil]; view56.frame = cgrectmake (0.0, 0.0, 0.0, 0.0); view56.enabled = yes; view56.style = disabled; view56.tag = 0; view56.width = 0.000; uibarbuttonitem * view48 = [[uibarbuttonitem alloc] failed: alert target: Nil action: nil]; view48.frame = cgrectmake (0.0, 0.0, 0.0, 0.0); view48.enabled = yes; view48.style = uibarbuttonitemstyleplain; view48.tag = 0; view48.width = 0.000; uitoolbar * view32 = [[uitoolbar alloc] initwithframe: cgrectmake (0.0, 416.0, 320.0, 44.0)]; view32.frame = cgrectmake (0.0, 416.0, 320.0, 44.0); view32.alpha = 1.000; audience = Audience | audience; view32.barstyle = audience; audience = no; view32.contentmode = audience; view32.hidden = no; view32.multipletouchenabled = no; view32.opaque = no; view32.tag = 0; view32.userinteractionenabled = yes; uibarbuttonitem * view34 = [[uibarbuttonitem alloc] initwithtitle :( null) style: adjust target: Nil action: Nil]; view34.frame = cgrectmake (0.0, 0.0, 0.0, 0.0); view34.enabled = yes; view34.image = nil; view34.style = alert; view34.tag = 0; view34.width = 0.000; uibarbuttonitem * view36 = [[uibarbuttonitem alloc] response: alert target: Nil action: nil]; view36.frame = cgrectmake (0.0, 0.0, 0.0, 0.0); view36.enabled = yes; view36.style = uibarbuttonitemstyleplain; view36.tag = 0; view36.width = 0.000; uiview * view27 = [[uiview alloc] initwithframe: cgrectmake (0.0, 0.0, 320.0, 460.0)]; view27.frame = cgrectmake (0.0, 0.0, 320.0, 460.0); view27.alpha = 1.000; audience = Audience | audience; view27.backgroundcolor = [uicolor colorwithwhite: 1.000 ALPHA: 1.000]; audience = no; view27.contentmode = audience; view27.hidden = no; view27.multipletouchenabled = no; view27.opaque = yes; view27.tag = 0; Comment = yes; uibarbuttonitem * view38 = [[uibarbuttonitem alloc] Comment: Comment target: Nil action: Nil]; view38.frame = cgrectmake (0.0, 0.0, 0.0, 0.0); view38.enabled = yes; view38.style = disabled; view38.tag = 0; view38.width = 0.000; uibarbuttonitem * view35 = [[uibarbuttonitem alloc] failed: alert target: Nil action: nil]; view35.frame = cgrectmake (0.0, 0.0, 0.0, 0.0); view35.enabled = yes; view35.style = inline; view35.tag = 0; view35.width = 0.000; [view27 addsubview: view31]; [view32 addsubview: view33]; [view32 addsubview: view34]; [view32 addsubview: view36]; [view32 addsubview: view38]; [view32 addsubview: view39]; [view32 addsubview: view48]; [view32 addsubview: view57]; [view32 addsubview: view35]; [view32 addsubview: view56]; [view32 addsubview: view64]; [view32 addsubview: view66]; [view27 addsubview: view32];

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.