ios - In objective-c is it always wrong to repeat a bunch of code or are there occasions where it doesn't matter? -
Take a look at my I was thinking about how to put the repetitive code in another method and pass it in the cell and remember the cellophore ITINETPath but remembered that they were different classes. Code: Question: Is this a great deal? What will you do in this situation? I decided to use two different cells instead of using one and changing the lack of properties because it really got dirty. Please enter Two cell variables There is no reason. The only conditional part of this function is that on the object you are working on, you can only assign a variable conditionally. UICollectionView data source method below if I repeat myself in the statement Basically, I am setting the properties in two different custom
UICollectionViewCell's . They have the exact same properties and the differences between these cells are only visible differences.
- See the (UICollectionViewCell *) collection: (UICollectionView *) collectionView cellForItemAtIndexPath: (NSIndexPath *) IndexPath object: (Pfbject *) Object {NSLog (@ "Calendous 1 Loaded"); Fixed NSString * CellIdentifier = @ "cell"; VAGGarmentCell * cell = [_collectionView dequeueReusableCellWithReuseIdentifier: cell-indexed for indexpath: indexpath]; Fixed NSString * cell identifier 2 = @ "cell2"; VAGGarmentCell2 * cell2 = [_collectionView dequeueReusableCellWithReuseIdentifier: cell identifier2 forIndexPath: indexPath]; If ([[_collectionView archive ViewLayout] is Aww: _flowLayout]) [[Started cell activity indicator] permission]; PFFile * userImageFile = [Object Value forKey: @ "Image"]; [[Cell Image View] setFile: userImageFile]; [[Cell image view] Load Inboxing]; [[Cell Activity Indicator] Stop Animating]; [[Cell title] Set text: [object value forekki: @ "title"]]; [[Price of cell] Set text: [NSSTING string with format: @ "£% @ GBP", [Object Whirlfire: @ "Price"]]]; Return cell; } And if ([[_collectionView archive ViewLayout] is Aww: _flowLayout2]) {{Cell 2 Activity Indicator] Start Permission]; PFFile * userImageFile = [Object Value forKey: @ "Image"]; [[Cell2 image view] setFile: userImageFile]; [[Cell 2 image view] Load these backgrounds]; [[Cell 2 Activity indicator] Stop Animating]; [[Cell 2 headline] Set text: [object value forekki: @ "title"]]; [[Cell2 value] set text: [NSString stringWithFormat: @ "£% @ GBP", [Object Value: Forex: @ "value"]]]; Return cell 2; } Return 0; // _ addToFavouritesButton = [cell addFavouriteButton]; [_addToFavouritesButton addTarget: _this controller action: @Selector (addToFavouritesButtonTapped :) Control events: UIControlEventTouchUpInside]; }
- (UICollectionViewCell *) collection: (UICollectionView *) collectionView cellForItemAtIndexPath: (NSIndexPath *) indicatorPass object: (PFObject *) Object {NSLog (@ "Collection View 1 Loaded"); Fixed NSString * CellIdentifier = @ "cell"; Fixed NSString * cell identifier 2 = @ "cell2"; VAGGarmentCell * cell = zero; If (([[_collectionView Collection ViewLayout] is Equal: _flowLayout] {cell = [_collectionView dequeueReusableCellWithReuseIdentifier: For CellEdentifierIndexPath: indexPath];} Else if (([[_collectionView collectionViewLayout] is: _flowLayout2]) {cell = [_collectionView dequeueReusableCellWithReuseIdentifier : [[Cell image view] setFile: userImageFile]; [[cell image view] load inbaked]: [[Cell image view]]; [[Cell image view]] [[Cell image view] ; [[Cell Activity Indicator] Stop Animating]; [[Cell Title] Set Text: [Object Value: Forex: @ "Title"]]; [[Price of Cell] Set Ekst [Ansstiing string with the format: @ "£% @ GBP", [object Whrlfayr: @ "price"]]]; return cell;}
Comments
Post a Comment