开发者

Xcode: Split code in multiple files

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


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);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜