objective c - Should I Add Something To The Header File? -


i'm writing app , getting error. not sure how go fixing it. thank you.

the error undeclared identifier 'collectionview'

and header file being imported.

header:

#import <uikit/uikit.h> nsmutabledata *content;  @interface amcollectionviewcontroller : uicollectionviewcontroller   @property (weak, nonatomic) iboutlet uibarbuttonitem *tagbutton;  - (ibaction)tagbuttontouched:(id)sender;  @end 

implementation error occurring

- (void)collectionview:(uicollectionview *)collectionview didselectitematindexpath:(nsindexpath*)indexpath {     if(shareenabled){         //determine selected items using indexpath         nsstring *selectedphotos = [tagimages[indexpath.section] objectatindex:indexpath];          //add selected image array         [selectedphotos addobject:selectedphotos];     } } 

thanks lot guys

i use collectionview multiple times in same .m file

- (nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section{      return 50;  } 

- (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath{         static nsstring *identifier =@"cell";          amcollectionviewcell *cell = (amcollectionviewcell *)[collectionview dequeuereusablecellwithreuseidentifier:identifier forindexpath:indexpath];          int imagenumber = indexpath.row % 10;            cell.imageview.image = [uiimage imagenamed:[nsstring stringwithformat:@"imageicon%d.jpg",imagenumber]];         cell.selectedbackgroundview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"imageborder.jpg"]];           return cell;     } 

i don't know error,

  1. your second reference indexpath on line can't right:

    nsstring *selectedphotos = [tagimages[indexpath.section] objectatindex:indexpath]; 

    the objectatindex parameter needs integer. meant:

    nsstring *selectedphotos = [tagimages[indexpath.section] objectatindex:indexpath.item]; 

    or, more consistent (either use objectatindex or use [] syntax, using both little curious):

    nsstring *selectedphotos = tagimages[indexpath.section][indexpath.item]; 
  2. you haven't shown declaration of tagimages, nor it's initialization, assume tagimages array of array of strings? if so, above correction should fix it. if not, should tell how tabimages populated/structured.

  3. if selectedphotos nsstring, use of addobject method won't possibly work. addobject method nsmutablearray method, not nsstring method.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -