To View ProfilePicture in Xcode of facebook user - objective-c

When i am using
self.profilePic.profileID = user.id;
i end up with this error
-[UIView setProfileID:]: unrecognized selector sent to instance 0x69626f0
2012-09-11 09:49:50.535 TweetApp[992:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setProfileID:]: unrecognized selector sent to instance 0x69626f0'
can anyone help on this topic??

You can fix this issue simply. Just put this line code [FBProfilePictureView class]; at the first line of method application:didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FBProfilePictureView class];
//...
return YES;
}

I believe you are talking about Facebook Scrumptious sample project. If that is the case, you have to set the Class of UIView control to FBProfilePictureView

I had the same problem, itsaboutcode is right. Call [FBProfilePictureView class]; in your AppDelegate and the problem will be fix
++

Let's do it step-by-step.
self.profilePic refers to your property of UIView type.
Then you are trying to set this property's property profileID, but UIView class doesn't have such and you get the exception.
It will be easy for you to understand in the future from the error message, pay attention to the reason:
'-[UIView setProfileID:]: unrecognized selector sent to
instance 0x69626f0'
It tells you the method -setProfileID: is called for UIView* object and with the code you posted it is clear why it happens.
I suppose you have profileID property in the view controller, then you'll want to use
self.profileID = user.id;
Or if self.profilePic should support profileID property then you initialized it incorrectly, find the initialization place to see what happens.

I faced the same problem make sure your profile pic is an instance of FBProfilePictureView go to your layout and change the class of your view to be FBProfilePictureView notice your fb profile pic is a UIView not an ImageView that means u need to add view and change its class to FBProfilePictureView not an ImageView
also add this line at the first of your app delegate [FBProfilePictureView class];

Related

Objective-C Code throws 'Unrecognised Selector' for the 'sender' selector

I am fairly new to apps and Objective-C as a whole. I was creating a slider that sends it's output to a label displaying the number. Here is the code:
- (IBAction)sliderChanged:(id)sender {
UISlider *slider = (UISlider *)sender;
self.sliderText.text = [NSString stringWithFormat:#"%f", slider.value];
}
And behold the error:
2014-01-10 17:17:29.037 tapbuttonipad[64226:70b] -[NSViewController sliderChanged]: unrecognized selector sent to instance 0x8a6f450
2014-01-10 17:17:29.061 tapbuttonipad[64226:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSViewController sliderChanged]: unrecognized selector sent to instance 0x8a6f450'
The slider is linked to that block of code. I am unsure as to what I am doing wrong.
Any help is greatly appreciated.
EDIT:
Someone who answered but then deleted their answer was actually correct, and now my app does not crash. However, the app still does not update the label that it was meant to. I changed it from setting the value to just setting #"test", but it still did not change.
ANOTHER EDIT:
Darn, I am stupid. I had my label variable as a text field instead of a label... gah! Anyway, this is completely fixed now. Thanks everyone!
You should change the class of your view controller in your xib/storyboard to your NSViewController subclass:
Select your view controller in object inspector
In Identity inspector specify the name of your NSViewControllerSubclass in Custom Class field
Alright. I have fixed it. Firstly, it would throw an error as the slider was linked to the IBOutlet when it was without a colon, and I did not update it. After updating it worked fine.

Difficulty implementing delegate methods in an objective-c project

I have a table view which I am using as a form.
The first cell has an editable text field. The second cell, when clicked, loads a semi modal date picker. I used this: http://reednj.tumblr.com/post/1346445326/ios-semi-modal-date-picker-for-iphone
Anyway, I've defined my datepicker and set its delegate inside the tableviewcontroller like so:
TDDatePickerController* datePickerView = [[TDDatePickerController alloc]
initWithNibName:#"TDDatePickerController"
bundle:nil];
[datePickerView setDelegate:self];
[self presentSemiModalViewController:datePickerView];
Now the methods to handle the button clicks are defined as
-(void)datePickerSetDate:(TDDatePickerController*)viewController;
-(void)datePickerClearDate:(TDDatePickerController*)viewController;
-(void)datePickerCancel:(TDDatePickerController*)viewController;
So when the cancel button is pressed I would like the semi-modal date picker to be dismissed, So I've got:
-(void)datePickerCancel:(TDDatePickerController*)viewController{
[self dismissSemiModalViewController:viewController];
}
But this makes the app crash with the error
-[__NSCFType cancelDateEdit:]: unrecognized selector sent to instance 0xe738c00
2012-09-18 10:23:47.254 JRPBaseCamp[7612:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType cancelDateEdit:]: unrecognized selector sent to instance 0xe738c00'
So I looked up the cancelDateEdit method in TDDatePickerController:
-(IBAction)cancelDateEdit:(id)sender {
if([self.delegate respondsToSelector:#selector(datePickerCancel:)]) {
[self.delegate datePickerCancel:self];
}
}
What am I doing wrong? It must be something obvious that I'm overlooking. Any help is much appreciated, I'm fairly new to iOS and the whole concept of delegates is really confusing me.
Thanks!
The unrecognized selector sent means nothing is responding to cancelDateEdit: selector. You can use the debugger to search what kind of object is 0xe738c00 and then look for the appropriate selector there.

[__NSCFType searchKeyword:]: unrecognized selector sent to instance 0x6d8eb80

The following code is to add a subview to current view from storyboard:
EventSearchViewController* view1 = [self.storyboard instantiateViewControllerWithIdentifier:#"searchView"];
[view1 setBookingSystem:system];
[self.view addSubview:view1.view];
In the view "view1", there is a textField. The following is a IBAction to the textField and the event is "Did end on exit".
-(IBAction)searchKeyword:(id *)sender
{
NSLog(#"searchKeyword");
}
The following is the error message.
2012-05-26 20:26:47.369 OnlineBooking[6607:f803] -[__NSCFType searchKeyword:]: unrecognized selector sent to instance 0x6d8eb80
2012-05-26 20:26:47.369 OnlineBooking[6607:f803] * WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate: -[__NSCFType searchKeyword:]: unrecognized selector sent to instance 0x6d8eb80
You need to retain your EventSearchViewController, or keep a strong reference to it if you're using ARC. If you assign it to view1 as a local variable, it's not going to be around any more when searchKeyword: gets called. (The error shows that its memory has been released and re-used for a different type of object.)
For me the problem was that I never called
- (void)removeTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
before I called
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
again.

Objective-C Declaring object as a totally different class than what I declared

In a method I wrote, I'm declaring an instance of class 'A' and calling a method on it. At run time, when the method runs, my app crashes. It says an unrecognized selector was sent to an instance of class 'B' even though I declared an instance of 'A'. I read somewhere that I may not be managing my memory correctly so it's sending the method to another class, but I'm using ARC so that shouldn't even be a problem. Help would be much appreciated!
The error I'm getting:
2011-08-27 01:25:49.859 Intelligenda[49385:bc03] PVC: <HomeViewController: 0x59359e0>
2011-08-27 01:25:49.945 Intelligenda[49385:bc03] -[HomeViewController addNewClass:]: unrecognized selector sent to instance 0x59359e0
2011-08-27 01:25:49.947 Intelligenda[49385:bc03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[HomeViewController addNewClass:]: unrecognized selector sent to instance 0x59359e0'
and the method that's being called:
-(IBAction)done:(id)sender{
[teacherName resignFirstResponder];
[className resignFirstResponder];
IntelligendaAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
UINavigationController *nav = delegate.navController;
[nav popViewControllerAnimated:YES];
ClassesViewController *classesParentViewController = (ClassesViewController *) nav.topViewController;
ClassIG *theNewClass = [[ClassIG alloc] init];
theNewClass.className = className.text;
theNewClass.teacherName = teacherName.text;
NSIndexPath *indexPath;
theNewClass.subject = [tableView cellForRowAtIndexPath:indexPath].textLabel.text;
// add reminder to array
NSLog(#"PVC: %#", [classesParentViewController description]);
[classesParentViewController addNewClass:theNewClass];
}
Declaring, say, a pointer NSArray* fred does nothing (other than a sprinkling of compile-time warning messages) to assure that fred is an NSArray. It's what you assign to fred that counts. If you assign an NSDateFormatter, then that's what fred is.
Your assumption that the application delegate's navigation controller has a ClassesViewController on top is clearly flawed. It has a HomeViewController on top. Your structure looks like it may be a little complicated, given that you have a button somewhere wired up to an action in some other part of your controller classes, so there could be a bunch of causative reasons.
First things to check: if you're instantiating buttons programmatically then did you accidentally add the button to the wrong controller? If you're designing everything using the graphical interface designer but keeping it in a single NIB, is it possible you copied and pasted a button and forgot to change what it's wired to?
If you can end up with multiple navigation controllers, are you sure the one held by the application delegate is currently on screen?
the short answer is that typecasting and type conversions are an exercise for the programmer in objc.
read my answer here:
Passing NSNumber* to NSString* expected-parameter does not cause compiler warning / error
...for some more information as to how declaring/casting a variable of an object differs from other languages, and how you can detect those cases.

How to Assign a UITextField to a NSString (with UITouchEvent error?)

I'm simply trying to assign a UITextField.text to an NSString in my object.
The code errors out when I try to print the enteredLocation.text but I have no idea why. I thought it was a type mismatch, but both are NSString. Any idea?
- (IBAction) submitPushed: (UITextField*)enteredName: (UITextField*)enteredCell: (UITextField*)enteredLocation;
{
ExampleAppDataObject* theDataObject = [self theAppDataObject];
NSLog(#"LOC %#", enteredLocation.text);
theDataObject.location = enteredLocation.text;
NSLog(#"DATAOBJ %#", theDataObject.location);
}
I always get this error:
2011-08-20 10:28:13.602 ViewControllerDataSharing[3188:207] -[UITouchesEvent text]: unrecognized selector sent to instance 0x4e07780
2011-08-20 10:28:13.607 ViewControllerDataSharing[3188:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITouchesEvent text]: unrecognized selector sent to instance 0x4e07780'
But UITouchEvent? How does that relate? I ctrl-clicked the button to the method in my .m file. Is there a step missing? I tried checking if the text is "", but it won't even get that far.
I have the I'm a major newbie, so thanks in advance. I've read 100s of answers on this site, and love it!! So helpful!
THANKS!
Mark
When the action fires for your button, the method signature will look like one of these:
-(IBACtion)onPushed; // no parameters
-(IBAction)onPushed:(id)sender; // sender is the control that initiated the event
-(IBAction)onPushed:(id)sender event:(UITouchesEvent*)event; // event is the touch event that caused the event
You can't control what gets passed to your handler by changing the parameters. If you need to access the text field, make sure there is an IBOutlet reference to the UITextField object in your class (and hook it up in IB) and use that to access it.
I'm guessing that you have the IBAction hooked up to the wrong action in your nib - one that is a touch event. If you try:
NSLog(#"Param1: %#", enterdLocation);
You'll see that the method is being passed a UITouchesEvent object instead of a UITextField object.
Double-check your nib connections.