Archive

Archive for September, 2010

Private method in Objective-C

There are no private methods in Objective-C like e.g. in C# .NET. Though you can create a category with an empty name (class continuation) in Objective-C 2.0 (i.e. @interface MyClass ()). With this category you can create the private method implementations in the same @implementation MyClass file as the public methods.

With an addition like “__” at the start of your “private” methods you should bring in this naming convention to prevent your classes from being breakable in a too easy way. The possibility that someone will override some of your “private” methods by accident is then on a much lower value. Apple reserved names with a leading underscore for its own uses, so prefer an addition like “__”.

Create your classes for example like this:

In the header file:

@interface MyClass {
    // My Instance Variables
}

- (void)myPublicMethod;

@end

And in the implementation file:

@interface MyClass(/* Private methods */)

- (void)__myPrivateMethod;

@end

@implementation MyClass

- (void)myPublicMethod {
    // Implementation goes here
}

- (void)__myPrivateMethod {
    // Implementation goes here
}
@end

The second alternative is to put the category into its own .h file. You can name such a file after its class and category with a + separating them, so @interface MyClass (PrivateMethods) can be found in MyClass+PrivateMethods.h. With this convention you can import the header in your unit test classes.

Advertisements
Categories: CodeSnippets, iOS, Objective-C

couldn’t determine absolut path of file…

Got this error message when a directory was deleted on the svn server. A new checkout solved the problem.

Categories: SCM, Xcode

Installing Git

Download latest stable Git release from here and install it.

You can get a version via Git with:

git clone git://git.kernel.org/pub/scm/git/git.git

Categories: Mac OS X, Xcode

Windows 7 Autostart-Programme

Im Startmenü “msconfig” suchen. In dem Fenster den Reiter “Systemstart” auswählen und Autostart-Programme aktivieren und deaktivieren. Den Ordner mit den Autostart-Programmen befindet sich außerdem unter Start / Alle Programme / Autostart bzw. C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

Categories: Windows 7

Relationship does not have an inverse

Apple wants you to have inverse relationships. See Core Data documentation:

“It is possible for relationships to be navigable in only one direction (if you are never interested in finding out from a department object what employees are associated with it, then you do not have to model that relationship), however you are strongly encouraged always to model relationships in both directions.”

But perhaps yout don’t want/need an inverse relationship between two entities. To disable the XCode model compiler warnings simply check the box to ‘Suppress momc warnings on missing inverse relationships’.

Categories: Xcode

iPhone dimensions

Portrait mode

Element Size
Status bar 320 x 20 px
Navigation bar 320 x 44 px
Tool bar 320 x 44 px
Tab bar 320 x 49 px
Keyboard 320 x 216 px
Text Field … x 31 px
Total screen 320 x 480 px

sizes

Categories: iOS

Format sourcecode

Edit->Format->Re-Indent

You can set a shortcut for this:

xcode shortcuts

Categories: Xcode