views:

59

answers:

1

Hello

I'm using a new class with nib and tableview. To costumize the TableViewCells i have defined some functions and constant values (#define) and special TableViewCells

 - (UITableViewCell*) CreateMultilinesCell :(NSString*)cellIdentifier { ... }

I want to use this costumized cell in other TableViews too. Is it possible to pack this specific code into a file and load it into multiple files ? like inlcude in PHP

From comment: What is the most reduced (OO-free, just functions) file possible in iPhone SDK ?

i hope you understand what i mean. cheers Simon

A: 

Create a function and put it in it's own file, and create a header and include that and call that function.

Like this:

  • CellCreator.m: UITableViewCell *CreateMultilinesCell(NSString *cellIdentifier) { ... }

  • CellCreator.h (and be sure to #include <UIKit/UIKit.h>): UITableViewCell *CreateMultilinesCell(NSString *cellIdentifier);

  • Your TableView files (at the top): #include "CellCreator.h"

  • To use it: UITableViewCell *cell = CreateMultilinesCell(@"identifier);

chpwn
As far as I tried do I have to create a NSObject, but my goal was to use a bunch of standartfunctions without creating a new instance of my class. Is my desire against OOP ?Simon
Simon
You don't have to make a class for everything. OOP isn't always the right solution...
chpwn
but i'm getting errors with no @interface.What is the most reduced (OO-free, just functions) file possible in iPhone SDK ?Sorry, but I'm really struggling with this.
Simon
Just create it as you would in C. Objective-C is a strict superset of C, so just create is as a standard .c file (but named .m, of course).
chpwn
big thanx !!!!!
Simon