ios - Creating a class cluster in objective c - methods called on abstract super class? -


I am trying to create a cluster cluster for a UITableViewDatasource, my interface looks like this:

  @interface ArrayDataSource: NSObject & lt; UITableViewDataSource & gt; - (id) initWithItems: (NSArray *) Item Cell Identifier: Configure (NSString *) cellIdentifier; Call Block: Block (Configure TableViewCellConfigureBlock) configuration; - (id) initWith2DArray: (NSArray *) array section identifier: Configure (NSArray *) cellIdentifiersCallBlock: (TableViewCellConfigureBlock) block configuration; - (id) MadAttindAppath: (NSIndexPath *) indexpath; Internal interval, the intangible square looks like this:  
  @implementation ArrayDataSource - (ID) initWithItems: (NSArray *) Item Cell Identifier: (NSString)   *) Cell Identifier Configure CallBlock: (TableViewelle Config Blocks) ConfigurationBlock {Return [[SingleArrayDatasAloc] with InuitHat Item: Item Cell Identifier: Configure Cell IdentifierCellBlock: ConfigurationBox]; } - (ID) initWith2DArray: (NSArray *) array section identifier: Configure cellIdentifiers (NSArray * )CallBlock: (TableViewCellConfigureBlock) ConfigurationBlock {return [[Two dimensional array data source alloc] initWith2DArray: array sectionIdentifiers: Configure cell identifierCellblocks: block configuration ]; }   

Now, to make the compiler silent, who is complaining that the abstract class (arreteaters) has not implemented the UTviewView data required methods, I have added them: / P>

  #pragma icon - override - (id) items endpath: (NSINXAP *) indexpath {return zero; } - (NSInteger) numberOfSectionsInTableView: (UITableView *) table view {return 0; } - (NSInteger) Table view: (UITableView *) table view numberoffrose injection: (NSInteger) section {return 0; } - (UITableViewCell *) TableView: (UITableView *) Table View CellForAind Pound: (NSIndexPath *) indexPath {return zero; }   

But whenever I use the cluster, the data source method goes to the intangible class! If I remove those overrides, then everything works desirable (I still have compiler warnings).

What's going on? Why do those messages go into the abstract class when the example SingleArrayDatasource or two-based alarms data source

UPDATE < P> Here I have applied one of the solid subclasses

@implementation SingleArrayDatasource

  - (id) initWithItems: (NSArray *) Item Cell Identifier: (NSString * ) Configure cell identifier: call block (tableviews configured ball) configuration block {self = [super init]; If (self) {self.items = items; Self.cellIdentifier = cellIdentifier; Self.configureCellBlock = [copy configurationBlock]; } Healthy return; } - (id) MadAindind Path: (NSINXPath *) IndexPath {Return Self. Items [indexpath.ro]; } #pragma Icon UITableViewDataSource - (NSInteger) TableView: (UITableView *) table view numberOffrosion Insub: (NSInteger) section {return self.items.count; } - (UITableViewCell *) TableView: (UITableView *) Table View CellForouaitindPath: (NSIndexPath *) Index Path {ID Cell = [Table View dequeueReusableCellWithIdentifier: self.cellIdentifier forIndexPath: indexPath]; Id items = [auto-itemaddexexpath: indexpath]; Self.configureCellBlock (cell, item); Return cell; }    

Your problem is arising because Objective C does not really have the abstract type , But at least it does not do that Java does.

In addition, you are returning a morphed type from init, which are examples of ways, which means that you are already working on an example of "abstract type" - which is ineligible.

I recommend that you use a factory pattern in your "abstract class" -

  @implementation ArrayDataSource + (id) dataSourceWithItems: (NSArray *) item cell identifier Configure Cell Identifier (NSString *) Cell IdentifierCallBlock: (TableViewelle Config Balls) ConfigurationBlock {Return [[SingleArrayDatasAloc] InitHat Items: ItemsSil Identifier: Configure Cell IdentifierCellBlock: ConfigurationBox]; } + (Id) dataSourceWith2DArray: (NSArray *) array section identifier: Configure cellIdentifiers (NSArray *) CallBlock: (tableviews configured ball) configuration lock {return [[two-dimensional array data source alloc] initWith2DArray: array sectionIdififier: Configure cell identifierCellblock: Block configuration]; }   

These are class methods, so it is valid for calling alloc and init

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -