trying to reload table but giving exception 'NSInvalidArgumentException' - iphone

I am having a tableview which i created using iboutlet.and when i am trying to reload table it is giving this exception.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x5949310'
IBOutlet UITableView *tableStudent;
here is .h and .m files.
.h
IBOutlet UITableView *tableStudent;
-(IBAction)enabeluser;
.m
-(IBAction)enabeluser{
[tableStudent reloadData];
}

your array has got released at that time you call realodData method.

NSInvalidArgumentException occur when you refer to non-existing object. You might have release datasource or tableview object in the class.

Related

dismissModalViewControllerAnimated not working on XIB

I have an XIB that I present as a modal view. I have a button that calls the following -
(IBAction)dismissVC:(id)sender {
[self.parentViewController dismissModalViewControllerAnimated: YES];
}
When I press it the app crashes with this notice -
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController dismissVC:]: unrecognized selector sent to instance 0x8379350'
The thing I noticed is that I have a ViewController.xib file and I have this MapView.xib that is a modal VC I want to dismiss. It's presented from a ViewController.xib
What could be the possible issue? I've hooked up all the actions and the File Onwer thing as well.
Thanks in advance!
Try this:
unrecognized selector sent to instance
that might be your solution.

Managing multiple UIActivityIndicatorView

I have defined IBOutletCollection of UIActivityIndicatorView.
IBOutletCollection(UIActivityIndicatorView) NSArray *ticker;
After making the required connections in the Interface builder, I run the following code.
for (UIActivityIndicatorView *obj in ticker)
{
[obj startAnimating];
}
But I get this message on the console:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIActivityIndicatorView countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x2c86a0'
I know it might be a very small problem with it, but really not getting it.
Thanks!
I don't know what it's not working for you. I have done the following and it works fine.
in my .h
#property (strong, nonatomic)IBOutletCollection(UIActivityIndicatorView) NSArray *activityIndicators;
in my .m (if not using Xcode 4.4)
#synthesize activityIndicators
I added 7+ activity indicators to my StoryBoard and connected them to my viewController
in my viewDidLoad i'm calling
for (UIActivityIndicatorView *obj in self.activityIndicators){
[obj startAnimating];
}
Works fine for me in this configuration no problems.
Based on the error message you're getting
'NSInvalidArgumentException', reason: '-[UIActivityIndicatorView countByEnumeratingWithState:objects:count:]
Sounds like something not set right, check your IB that you haven't done something odd.
The method countByEnumeratingWithState:objects:count: is supposed to be sent to the array object as part of the NSFastEnumeration protocol. Sometimes messages can get sent to the wrong object if there's a memory issue. Double-check to make sure that ticker is being properly retained (and it might also be best practice to use self.ticker).

Strange receiver/selector errors from numberOfSectionsInTableView iPhone SDK reported from Flurry

I'm using Flurry to track stats of my iPhone app, and lately I've been seeing several REALLY weird errors. Seemingly random objects are receiving a "numberOfSectionsInTableView" message, and I have no idea how/why. The app was built using the 4.2.1 SDK and targeted for iOS 4.0 devices. Here is a snippet of some examples:
NSInvalidArgumentException: -[NSCFString numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x4f3de10
NSInvalidArgumentException: -[__NSCFData numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x4f55bc0
NSInvalidArgumentException: -[NSPathStore2 numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x4f5ebc0
NSInvalidArgumentException: -[__NSCFType numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x2ac5f0
NSInvalidArgumentException: -[PLPhoto numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x2fbc30
NSInvalidArgumentException: -[PLPhotoLibrary numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x725ea20
I'm only specifying numberOfSectionsInTableView in my usual UITableView delegate methods, not calling it directly. The only code I found that calls this method directly was in the ASIHTTPRequest library:
if (section == [self numberOfSectionsInTableView:aTableView]-1) {
return 30;
}
return 0;
But this was in "ASIAuthenticationDialog.m" and I'm not using auth with ASIHTTPRequest.
Has anyone seen anything like this before? I'm open to any and all suggestions, pretty stumped here, and unable to reproduce it so far.
Thanks.
Sounds like a classic over-release problem. You have over-released an object and some other random object is being messaged instead.
Turn on zombie detection and try your test case again.
I had same issue and my problem was that I created data source locally in method and it runs to same memory issue
- (void)setupDataSource {
/* some code to create sections */
TransactionDetailDataSource *dataSource = [[TransactionDetailDataSource alloc] initWithSections:sections];
self.tableView.dataSource = dataSource;
self.tableView.delegate = dataSource;
[self.tableView reloadData];
}
...So I had to create new property
#property (nonatomic, strong) TransactionDetailDataSource *dataSource;
and add this line
self.dataSource = dataSource;
at the end of method.

Connection fault in IB

I have a Tab Bar application with four new headers, implementation and interface files, and added those as the sources in IB. They were in this format: FirstView.h/m/xib, SecondView.h/m/xib.
I then had files for First-, Second-, Third- and FourthView.
There was also a file there called FirstViewController. I did not touch this, I just deleted it because I wasn't going to need it.
I then laid out my interface for the first view (FirstView.h/m/xib) in IB. It had an image on the top, label under and a UITableView under that.
I sat up the correct connections (delegations and datasource for the tableview) in my FirstView.h/m file, and pressed Build. It seemed to build without errors, so I pressed Build and Go.
The Simulator popped up, installed the app and crashed. (Error message:Terminating app due to uncaught exception).
Complete error message:
2010-02-06 21:50:54.733 Mudo[52439:207] *** -[FirstViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x39101a0
2010-02-06 21:50:54.735 Mudo[52439:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[FirstViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x39101a0'
2010-02-06 21:50:54.736 Mudo[52439:207] Stack: (**LotsOfNumbers**)
I asked about this in another question, got an answer, and that fixed it:
It was obviously looking for code in the FirstViewController.h/m-file, although I did not do anything to make it look for code there.
I fixed this by adding two interfaces and implementations in my FirstView.h/m file. (FirstView and FirstViewController)
When I ran the app then, the table view and tab bar came up on the screen, but my image and label did NOT.
I don't have any idea of why it was looking for the code in FirstViewController instead of FirstView... I have the correct connections in IB, too..
A tableview is trying to query its data source for the number of rows it should display. If you've connected the tableview's datasource outlet to an instance of your FirstViewController class, then you need to implement -tableView:numberOfRowsInSection: in that class.

Xcode iPhone SDK "Terminating app due to uncaught exception"

I have a problem with my application for the iPhone.
It's a tab based application. In one of the tabs, I have a Table View. I have set it up to load in data from a PLIST.
My problem is that when I try to build and run it, the application either crashes, or stays at a black screen with the error message "Terminating app due to uncaught exception".
I looked in the console, and found that the error probably laid in this string:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return workouts.count;
}
(error message:)
2010-02-06 21:50:54.733 Mudo[52439:207] *** -[FirstViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x39101a0
2010-02-06 21:50:54.735 Mudo[52439:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[FirstViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x39101a0'
2010-02-06 21:50:54.736 Mudo[52439:207] Stack: (
29344859,
2569487625,
29726779,
29296246,
29148866,
4413562,
4420938,
4419935,
3136474,
3076985,
3118420,
3106975,
55857840,
55857263,
55855302,
55854394,
2780921,
2804616,
2787027,
2814133,
37441233,
29129600,
29125704,
2780777,
2818051
)
Building the app does not generate any errors.
Please help me? Thanks :)
If you look at the actual text of the exception, 'NSInvalidArgumentException', reason: '*** -[FirstViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x39101a0', you can see the root of the problem. Somewhere in your code you're calling tableView:numberOfRowsInSection: on a FirstViewController, which doesn't implement that method.
Exceptions are not caught at compile-time, but rather thrown at runtime. You may want to read up on them if you aren't familiar, as they're a fairly important part of many programming languages.
http://en.wikipedia.org/wiki/Exception_handling
I'm guessing, since FirstViewController is one of the standard example classes created when starting a new Tab Bar based application in Xcode that you haven't changed its super class or implemented the methods of UITabeViewDelegate and UITableViewDataSource.
Either that or you've implemented the methods from those protocols in another class, but set FirstViewController as the table view's delegate/datasource.
We need more information to know for sure.