Giter Club home page Giter Club logo

xobjc's Introduction

Error in user YAML: (<unknown>): did not find expected alphabetic or numeric character while scanning an alias at line 1 column 1
---

**Deprecated, this code should not be used any more! Better use Xcode 4 with ARC!**

---

xobjc

Flattr this git repo

FULL XCODE4 COMPATIBILITY*

Xcode4 Demo on YouTube youtube.com/watch?v=Mzfv-ANydW4.

XCode3 Demo on mov.io mov.io/fE.

<iframe src='http://mov.io/go/showvideo/player/fE?autoplay=false' width='430' height='391' scrolling='no' frameborder='0'></iframe>

A tool for making annoying every day tasks for Objective-C developers, especially iPhone developers, easier. Therefore this tool will help you writing semi-automatically the @property and @synthesize stuff. It also updates the dealloc method to release your objects. And you can define the attributes according to the Google Objective-C Styleguide using a trailing underscore, i.e. your public attribute is then defined without this underscore. But also a leading underscore is ok. Public method can easily be defined by prepending XPUBLIC in the implementation part.

No more redundancies and nonsense typing orgies! You'll save a lot of time!

Preparations

You have to define some helpers in your code that will indicate your properties (you can alternatively use xobjc.h from this package):

#define XRETAIN 
#define XIBOUTLET
#define XASSIGN
#define XCOPY 
#define XPROPERTY(...)
#define XNIL nil
#define XPUBLIC 

Your code

In your header file mark you properties like this:

#import <UIKit/UIKit.h>
#import "xobjc.h"

@interface DemoViewController : UIViewController {
    XIBOUTLET UILabel *header_;
    XIBOUTLET UITextView *message_;    
    XASSIGN id delegate_;    
    XASSIGN int counter;    
    XRETAIN NSArray *listOfUsers_;    
    XCOPY NSString *secretKey_;
    XPROPERTY(readonly) BOOL isPublic_; 
    int age;
}

@end

In your module file you can mark public methods like this:

XPUBLIC
- (void)somePubMethod { /* ... */ }

(IBAction, class initializers and class methods are always considered public)

Usage

$ python xobjc.py sample.h

After that your .h and .m files are updated. XCode should reload your code in the editor automatically. The command also creates a new subfolder which contains a backup of your original code, hope you never will need it ;)

Example

Some pictures say more than thousand words. Here is a before/after diff showing the magic:

Header

Module

XCode4 Integration

Edit your projects 'Scheme' and add a new 'Run Script Action' to your 'Build / Pre-actions'. Fill in the full path of your xobjc4.py. Now each time you build your project this script will be run. This is super handy.

Header

If Growl is installed it will also issue a notification.

XCode3 Integration

In Xcode in the menu choose the script symbol and there Edit User Scripts. Create a new entry and copy and paste the contents of the file xobjc.py into the text field. That's all, you are done. Just call the script form the menu or via the key shortcut you defined while you are in the header or implementation file you like to become updated.

Related

Macro extensions for XCode

Similar approaches and discussions

Known Bugs and Problems

  • With Snow Leopard MacOS X 10.6 the 'osascript' helper, which is used for XCode integration, threw some errors. I used a workaround I found here to circumvent the problem: http://kb2.adobe.com/cps/516/cpsid_51615.html If you are using non Intel architecture or other OS you might need to modify this portion of code in xobjc.py

License (MIT License)

Copyright (c) 2011 Dirk Holtwick

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

xobjc's People

Contributors

holtwick avatar

Watchers

AAA avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.