And he’s back with another n00bic question.
Hi all,
I am having difficulties in saving text from text field to a string.
I wrote this method:
-(IBAction)saveTextForSharing:(id)sender{
NSString *textForSharing = [TextForSharing text];
}
Now there’s a semantic issue- Unused variable ‘textForSharing’.
Another method I wrote is that one:
- (IBAction)shareOnTumblr:(id)sender{
NSString *someText = *textForSharing;
}
and there’s that error:
Semantic Issue: Initializing ‘NSString *__strong’ with an expression of incompatible type ‘UITextField’.
Can someone help?
(And bring me a good guide for n00b from C to Objective C and iOS Development so I won’t trouble you answering my questions?)
Thanks!
EDIT:
I have compiled the project and I am having this error- Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1
plus I want to notify the user about what he’s going to post. I tried this-
NSString *someText = textForSharing;
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Confirm" message:(@"Are you sure you want to post %@ on your facebook wall?", *someText) delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
But it gives me- error:Experession result unused and error: Sending ‘NSString’ to parameter of incompatible type ‘NSString *’
What should I do?
Thanks in advance!
Make the
NSStringmembertextForSharingas class member variable (declare it in .h file).Here in your case, it is temp variable.
Also , in share method, make the line as follows,