0

.h

@interface HuntProfileView : UIViewController
@property (strong, nonatomic) NSString *huntgroupTitle;
@property (strong, nonatomic) NSString *huntgroupId;
@property (strong, nonatomic) NSArray *lines;
@end


.m

@interface HuntProfileView ()
@property (weak, nonatomic) IBOutlet UITextField *huntgrouptitleText;
@property HuntLineTable *childView;
@end

@implementation HuntProfileView

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"huntgroupTitle %@", self.huntgroupTitle);
    self.huntgrouptitleText.text = self.huntgroupTitle;
}


instantiation, assignment & execution

^{
    HuntProfileView *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"HUNTVIEW"];
    viewController.huntgroupId = huntId;
    viewController.huntgroupTitle = title;
    [self.navigationController pushViewController:viewController animated:YES];
 }

viewController.huntgroupTitle = title; is correct, or at least title is the string as expected.

The NSLog in .m outputs as:

2015-01-21 09:47:42.267 changeView[1108:16196] huntgroupTitle <UITextField: 0x7fa9a8fc8480; frame = (16 63; 568 30); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x7fa9a8fc9c70>>
2015-01-21 09:47:42.267 changeView[1108:16196] -[UITextField rangeOfCharacterFromSet:]: unrecognized selector sent to instance 0x7fa9a8fc8480
2015-01-21 09:47:42.270 changeView[1108:16196] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextField rangeOfCharacterFromSet:]: unrecognized selector sent to instance 0x7fa9a8fc8480'

Update:
I'm able to get successful execution when assigning self.huntgroupTitle a literal string ("hello, world"). Debugging has shown that at instantiation, both the input string of title as well as viewController.huntgroupTitle are confirmed to be the correct type.

Simon.
  • 1,886
  • 5
  • 29
  • 62
  • 1
    you should put a breakpoint at "viewController.huntgroupTitle = title;" and inspect title. If that doesnt work override the setter for "huntgroupTitle" and put a breakpoint there to check when it is assigned. – Aris Jan 21 '15 at 10:05
  • problem is not in your `ViewDidLoad` , check where u add the `rangeOfCharacterFromSet` in **.m** – Anbu.Karthik Jan 21 '15 at 10:05
  • Need more code. This usually happens when you accidentally assign the variable of an `NSString` type to a variable of type `UITextField`. – avismara Jan 21 '15 at 10:10
  • break point & variable inspection shows types are correct at that point. – Simon. Jan 21 '15 at 10:20
  • i myself never call `rangeOfCharacterFromSet`. which function does utilize it so i can pin point the problem? – Simon. Jan 21 '15 at 10:27
  • possible duplicate of [How can I debug 'unrecognized selector sent to instance' error](http://stackoverflow.com/questions/25853947/how-can-i-debug-unrecognized-selector-sent-to-instance-error) – Hot Licks Jan 21 '15 at 12:26
  • @Hot Licks the debugger didn't give me the answer to this, nor any useful insight. It was only as a last thought that i should check the storyboard source. This question has been resolved with my own answer, of which i'm unable to accept untill 2 days time – Simon. Jan 21 '15 at 12:33
  • The exception message told you what you needed to know -- you were assigning the wrong type of object. What you're calling an "NSString" is a UITextField. – Hot Licks Jan 21 '15 at 12:42
  • i disagree with you for the reason that all debug testing achieved was to inform me that somehow, the NSString property was being received as UITextView. no indication of location, or anything more. In all honestly, i'm getting sick of the negative response from this community. I explained my situation & gave everything available to me, and even provided the solution to it, of which non of the other answers were capable. yet all i received is criticism. – Simon. Jan 21 '15 at 12:58
  • Maybe it's time that you learned how to debug. Start by learning how to get the exception stack trace. – Hot Licks Jan 21 '15 at 21:16

2 Answers2

1

While initialising the HuntProfileView you must be assigning a UITextField to huntgroupTitle. Please check that.

I guess you might be doing something like this

HuntProfileView *huntV = [[HuntProfileView alloc] init];
huntV.huntgroupTitle = **some UITextField**;

instead it should be

HuntProfileView *huntV = [[HuntProfileView alloc] init];
huntV.huntgroupTitle = someTextField.text;

Please check. Thanks

Ganesh Somani
  • 2,280
  • 2
  • 28
  • 37
-1

The Storyboard source file had:

<connections>
  <outlet property="huntgroupTitle" destination="wx0-NH-iGn" id="P9H-Oe-AEm"/>
  <outlet property="huntgrouptitleText" destination="wx0-NH-iGn" id="Z1E-9e-lEn"/>
</connections>

Removing line with property "huntgroupTitle" resolved this

Simon.
  • 1,886
  • 5
  • 29
  • 62