Implementing countbyenumeratingwithstate for custom UICollectionviewCell - iphone

I am building an app with a CollectionView filled with custom CollectionViewCell.
I added a button "select all/deselect all" which is obviously supposed to affect all the cell in my collectionView. To do this I intended to use a for-loop like this:
for(customCollectionViewCell* cell in self.collectionView){
// some code
}
However i first get a warning saying:
Collection expression type "UICollectionView *" many not correspond to "countByEnumeratingWithStage:objects:count"
And when I compile the program and click on the button, the app crash with the following error message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionView countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x7973e00'
Does anyone have an idea on how to solve this?
Many thanks for your help!

Don't iterate the collection view itself, but rather the array of cells it returns by calling the visibleCells method on it.

Related

Error while running iPhone App Help - __NSCFConstantString error meaning

Could someone please tell me what this means:
2013-02-08 11:19:49.394 xxxxx[10545:907] set selected tab with tag 3
2013-02-08 11:19:49.560 xxxxx[10545:907] did select item
2013-02-08 11:19:49.562 xxxxx[10545:907] tab clicked
2013-02-08 11:19:49.566 xxxxx[10545:907] will show view controller MoreViewController
2013-02-08 11:19:49.567 xxxxx[10545:907] will show other VC
2013-02-08 11:19:49.579 xxxxx[10545:907] -[__NSCFConstantString offImage]: unrecognized selector sent to instance 0x21994c
2013-02-08 11:19:49.580 xxxxx[10545:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString offImage]: unrecognized selector sent to instance 0x21994c'
I just tried modifying some code, however the modifications did not work. So pressed z and undid everything I modified, but now I get this error.
The "unrecognized selector sent to instance" error always means one thing: you are calling a method on an instance that does not support it. In this particular case, you have a line in your code that looks like this:
[someObject offImage];
On this line, someObject is an instance of string, which does not have an offImage method.
This problem could be caused by passing an object of a wrong type to some other method:
[someTarget objectWithOffImage:#"Hello"];
The method could be expecting an object that responds to offImage, but you are passing it a string.
Finally, you may be trying to invoke a method in a category, but you forgot to import the header file for the category.
You are sending the message -offImage to an instance of NSString which does not have a method with that name. Alter your code so that -offImage is sent to the right kind of object

iOS - Video playing gives errors

When I follow this tutorial, it gives me an error on the [playercontroller release]; line, so I remove it, and then it gives me these errors when I try to run it.
I tried making another app to test the video, and it works seamlessly, but it will not work in my main app. Can anyone help?
And when I reimported the framework, and tried to play the video, it gives me this error:
2012-08-17 11:27:03.174 LYWAM Tour[768:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:
(0x1e15022 0x10fdcd6 0x1dbda48 0x1dbd9b9 0xba253b 0xba24c5 0x54ac 0x1e16e99 0x26314e 0x2630e6 0x309ade 0x309fa7 0x308d8a 0x2882cf 0x2885e6 0x26edc4 0x262634 0x16f7ef5 0x1de9195 0x1d4dff2 0x1d4c8da 0x1d4bd84 0x1d4bc9b 0x16f67d8 0x16f688a 0x260626 0x24cd 0x2435 0x1)
terminate called throwing an exception(lldb)
I take it GVE1ViewController is a class you wrote yourself? Does it definitely implement a method called GrommeVideoExcerpt1? Is what you assigned to the variable actually an instance of GVE1ViewController (or a subclass?) Put in an NSLog to check that it really is an instance of GVE1ViewController.
To do the NSLog, you need a line of the form:
NSLog(#" My controller = %#", myVar);
where myVar is whatever variable you have containing a reference to the GVE1ViewController.

NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array' when presenting view controller

I have developed an app that in testing has worked fine but when it has could live I have had some issues with crashes when presenting Modal View Controllers. The issue is in here some where:
NSLog(#"Looks like we made it here 1");
UIViewController *mtaViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"mtaViewController"];
NSLog(#"Looks like we made it here 2");
[mtaViewController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
NSLog(#"Looks like we made it here 3");
[self presentModalViewController:mtaViewController animated:YES];
NSLog(#"Looks like we made it here 4");
and my output to the console is:
2012-06-14 09:26:24.161 appname[2013:707] Looks like we made it here 1
2012-06-14 09:26:24.165 appname[2013:707] Looks like we made it here 2
2012-06-14 09:26:24.166 appname[2013:707] Looks like we made it here 3
2012-06-14 09:26:28.866 appname[2013:707] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x343ac8bf 0x345fc1e5 0x342f5b6b 0x6d3fd 0x6e719 0x3778e7ff 0x37798d53 0x37798cc1 0x37838339 0x3783714f 0x37891d97 0x7ce1d 0x7cd47 0x3788eaa5 0x3776a81b 0x3776ffb9 0x34ec1ba7 0x36fe0e8d 0x3437f2dd 0x343024dd 0x343023a5 0x30b86fcd 0x37783743 0x84327 0x6b468)
terminate called throwing an exception
I have set up in a function that I call when wanting to change view controllers and as you can see it makes it all the way down to "Looks like we made it here 3" so I suspect that there is an issue with line
[self presentModalViewController:mtaViewController animated:YES];
Can anyone help?
Check any array in mtaViewController, I dont see any array in your code so I'm thinking the issue is within mtaViewController. :)
Are you sure you view controller really gets initialized? Just an idea but this line
[mtaViewController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
would do nothing if mtaViewController would be nil. In Cocoa you can send messages to nil without problems. Your app only will crash later when you try to do something specific with them. Does
NSLog(#"%#", mtaViewController);
tell you something useful? Please make also sure you connected everything in IB that has to be connected (if you aren't working everything out in raw code).
By the way. This is deprecated. Use
presentViewController:animated:completion:
instead.

unrecognized selector sent to instance - mistake in properties?

I know that this question is asked for many times but i am working on it hard and can not find the mistake!
I have made a navigation based application.
To costumize the appereance of the table view cells i used this method in my RootViewController:
- (UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
Verwaltung Information * selectedFormel = [listOfFormularies objectAtIndex:indexPath.row];
cell.textLabl.text = selectedFormel.nameFormel;
return cell;
}
The variable "nameFormel" is declared in VerwaltungInformation as NSString with property and synthesize.
But instead I get this error message:
[FormelViewController nameFormel]: unrecognized selector sent to instance
Terminating app due to uncaught exception 'NSInvalidArgument', reason : [FormelViewControlle nameFormel]: unrecognized selector sent to instance
I need some help! Since days I have been working on it but I can NOT find the error...If somebody need some more details to answer, please leave a comment.
Your problem is that [listOfFormularies objectAtIndex:indexPath.row] returns an FormelViewController object, not an object of type VerwaltungInformation.
You should check your data (i.e. the listOfFormularies array).

trying to obtain an objects title variable gives unrecognized selector sent to instance

I have an object which holds a title and an indexReference. I save the object to an array and that works correctly.
I then try to load from the array and populate the tableview.
I use this code.
//fill it with contents
SavedFav *temp = [tableViewData objectAtIndex:indexPath.row];
cell.textLabel.text = temp.title;
I then get an error as the following
2010-07-01 15:42:46.386 Daily Quote[1308:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString title]: unrecognized selector sent to instance 0x23f6688'
What is causing this problem?
Thanks in advance.
"temp" is a string obviously, so it's too many answers to give, either you filled tableViewData with strings and trying to obtain title from a string (which is unrecognized) or you have problem with memory there, without seeing more code it's hard to say.
however try
cell.textLabel.text = temp;
and check what's inside, that will give you a good lead.