It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
.h
#property (strong, nonatomic) IBOutlet UITextField *responsibleField;
.m
#synthesize responsibleField;
responsibleField.text = [goal valueForKeyPath:#"responsibility.actorNaam"];
and actorNaam is of type String in my datamodel ..
and my textfield is correctly connected
Error:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet _isNaturallyRTL]: unrecognized selector sent to instance 0x6e8e9d0'
What could be wrong?
[goal valueForKeyPath:#"responsibility.actorNaam"]; is returning an object of type NSSet responsibleField.text is expecting an NSString. Check your code where you set the value for key path responsibility.actorNaam.
The object at goal.responsibility is an NSSet, invoking valueForKeyPath: on an NSSet returns an NSSet of the values at the specified keypaths.
If you just want to "pick one" from the set, use this:
[ [ goal valueForKeyPath:#"responsibility.actorNaam" ] anyObject ] ;
i.e. the question is which responsibility do you want?
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
how can I add an object in an array by clicking a button
I use this methode :
- (void)insertNewObject:(id)sender
{
[orderListe addObject:[[DataOrder alloc]initWithName:#"Michael" price:18 taille:#"junior" supplement:#"boeuf"]];
}
When I do that my application crash and say :
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DataOrder initWithName:]: unrecognized selector sent to instance 0x8aa4fa0'
What can i do to simply add an object to an array ?
Thank you
The error your getting has to do with the DataOrder object. During it's initialization it ran into an error. You're sending it some value it isn't expecting.
Perhaps try and separate the line where you alloc the Data Order object and try to add it to the array?
DataOrder *do = [[DataOrder alloc] initWithName....];
[orderListe addObject: do];
this will let you see where you messed up?
Of course that you can add an object to an array. The exception is thrown because the method initWithName:price: ... is not implemented in the DataOrder class.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have NSMutableArray data as below.
{
Id = "57\n ";
Image = "http://www.mysite.com/32f7aff4-9cb2-4044-a555-bfac8ea6eace.gif\n ";
NameEn = "salim\n ";
SpecializationsEn = "Dentistry\n ";
}
Now I wanted to get Imaage name hence I tried
[[feeds objectAtIndex:0] objectForKey:#"Image"]
but this is giving me error as
-[__NSDictionaryI objectAtIndex:]: unrecognized selector sent to instance 0x759b0b0
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI objectAtIndex:]: unrecognized selector sent to instance 0x759b0b0'
Any idea what is going wrong?
As far as I can tell from the data structure that you've posted, you don't have an array object but rather a dictionary object and a dictionary won't respond to objectAtIndex:.
Try replacing this:
[[feeds objectAtIndex:0] objectForKey:#"Image"]
With this:
[feeds objectForKey:#"Image"]
Or, if you prefer modern Objective-C syntax, this:
feeds[#"image"];
If you use NSMutableArray, then you should write[array valueForKey:#"key"];to retrieve elements from it
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
When i log a dictionary for example i get a output like this:
2013-04-18 16:24:45.905 pathFinderTest[9650:c07] -[__NSCFDictionary length]: unrecognized selector sent to instance 0x9271ee0
2013-04-18 16:24:45.912 pathFinderTest[9650:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary length]: unrecognized selector sent to instance 0x9271ee0'
*** First throw call stack:
(0x1c91012 0x10cee7e 0x1d1c4bd 0x1c80bbc 0x1c8094e 0x1c07c36 0x1c5113c 0x1cb64b6 0xb3c60a 0xb3c57c 0x2af7 0x28f8 0xf41c7 0xf4232 0x433d5 0x4376f 0x43905 0x4c917 0x25a5 0x10157 0x10747 0x1194b 0x22cb5 0x23beb 0x15698 0x1becdf9 0x1becad0 0x1c06bf5 0x1c06962 0x1c37bb6 0x1c36f44 0x1c36e1b 0x1117a 0x12ffc 0x22dd 0x2205)
libc++abi.dylib: terminate called throwing an exception
(lldb)
Now i know where the error was and in what file. But what if i didn't?
I'm used to java where it points to the correct file and the corresponding line number. Not that that is always the line where the problem is but often it is a good direction.
If you run the app using the debugger, when you encounter an exception, the Xcode debugger will show a stack trace. This will point you at the exact file and line in your app that caused the problem.
If this isn't happening then do the following in Xcode:
View the breakpoints pane on the left side of Xcode
Tap the + button in the bottom left corner and choose "Add Exception Breakpoint"
A new breakpoint appears along with a dialog. Accept the defaults and click on Done
Right-click on the exception and select "Move Breakpoint to" and choose "User"
Now debug your app and cause an exception. You should now get a useful stack trace in the debugger whenever you encounter an exception.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
My servlet on receiving first request from client:
//1.
ObjectInputStream in=new ObjectInputStream(req.getInputStream());
String r=(String) in.readObject();
in.close();
ObjectOutputStream writer = new ObjectOutputStream(resp.getOutputStream());
writer.writeObject(pk);
writer.close();
//ON receiving second request:
//2.
ObjectInputStream in1=new ObjectInputStream(req.getInputStream());
String s=(String) in1.readObject();
in1.close();
OutputStreamWriter writer1 = new OutputStreamWriter(resp.getOutputStream());
writer1.write(reverseStr);
writer1.close();
But on both request only 1. is getting executed. why?
I asked this question without actually studying servlets. A servlet's method(doPost(),doGet() etc) are each called time a request is made to the servlet. Only the init() method is initialized or executed only once.
So each time a call is made to the above servlet, it starts executing from #line1.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
NSObject * obj = [[NSObject alloc] init];
NSDictionary * dict = [NSDictionary dictionaryWithObject:obj forKey:#"test"];
For some reason gives me the following crash when executed :
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable
object'
I can't pinpoint what the issue is as I've done my homework and it seems to be valid code... I'm breaking my head over this!
I just ran your code without any problems. Are you sure it's not crashing after creating the dictionary? The exception you're getting seems to indicate that you're trying to add an object to the dictionary, which can't be done since NSDictionary is immutable. You need to use NSMutableDictionary if you want to add/remove objects after creation.