[twitter setInitialText:@"I just got", lastScore.text, @"on myappname"];
is passing list of three arguments to setInitialText. That's why you get the error message.
If you have a look at the documentation about NSString here
you will find out that you can concatenate string either by appending them or by creating a string with a specified format.
The first option would be
Code:
[twitter setInitialText:[[@"I just got " stringByAppendingString:lastScore.text] stringByAppendingString:@" on myappname"]];
which is not so convenient
And the second option would be
Code:
[twitter setInitialText:[NSString stringWithFormat:@"I just got %@ on myappname", lastScore.text]];
Where %@ gets replaced by lastScore.text.
__________________ SQLed - Your Database Manager on the go
[twitter setInitialText:@"I just got", lastScore.text, @"on myappname"];
is passing list of three arguments to setInitialText. That's why you get the error message.
If you have a look at the documentation about NSString here
you will find out that you can concatenate string either by appending them or by creating a string with a specified format.
The first option would be
Code:
[twitter setInitialText:[[@"I just got " stringByAppendingString:lastScore.text] stringByAppendingString:@" on myappname"]];
which is not so convenient
And the second option would be
Code:
[twitter setInitialText:[NSString stringWithFormat:@"I just got %@ on myappname", lastScore.text]];
Where %@ gets replaced by lastScore.text.
Suggestion:
Write an abstract explanation that tells the OP how to do it, but do not provide the exact code.
The OP will not learn as much (anything?) if he/she can just copy and paste code you've written into place.
If you post sample code, write it in general form, not an exact solution to the poster's question.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
[twitter setInitialText:@"I just got", lastScore.text, @"on myappname"];
is passing list of three arguments to setInitialText. That's why you get the error message.
If you have a look at the documentation about NSString here
you will find out that you can concatenate string either by appending them or by creating a string with a specified format.
The first option would be
Code:
[twitter setInitialText:[[@"I just got " stringByAppendingString:lastScore.text] stringByAppendingString:@" on myappname"]];
which is not so convenient
And the second option would be
Code:
[twitter setInitialText:[NSString stringWithFormat:@"I just got %@ on myappname", lastScore.text]];
Where %@ gets replaced by lastScore.text.
I have one other question with regards to fbconnect. Basically i am trying to do the same thing as twitter (be able to post high/latest scores) and i have the same sort of problem with the following code:
I have one other question with regards to fbconnect. Basically i am trying to do the same thing as twitter (be able to post high/latest scores) and i have the same sort of problem with the following code:
NSInvalidArgumentException', reason: '+[NSMutableDictionary dictionaryWithObjectsAndKeys:]: second object of each pair must be non-nil.
it would be much appreciated if you could help me with this as well!
Thanks again!
Ok, lets think. You just learned that you can't pass multiple parameters in place of a single parameter. You have to combine substrings. The OP told you that to create a combined string, you could use a temporary string:
Code:
NSString *tempString = [NSString stringWithFormat: @"The other string is %@", otherString];
You could then pass in tempString as a single parameter.
Are you passing in pairs of strings and values? No. You're making the same mistake with
Code:
@"I just got %@ on myappname", lastScore.text
You need to create a temp string in the line before you build your dictionary, and use stringWithFormat to fill it with the combined string you want to put in the "description" key value pair.
This time see if you can work out the code for yourself.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Ok, lets think. You just learned that you can't pass multiple parameters in place of a single parameter. You have to combine substrings. The OP told you that to create a combined string, you could use a temporary string:
Code:
NSString *tempString = [NSString stringWithFormat: @"The other string is %@", otherString];
You could then pass in tempString as a single parameter.
Are you passing in pairs of strings and values? No. You're making the same mistake with
Code:
@"I just got %@ on myappname", lastScore.text
You need to create a temp string in the line before you build your dictionary, and use stringWithFormat to fill it with the combined string you want to put in the "description" key value pair.
This time see if you can work out the code for yourself.
Thanks very much for all of your help!!!!!!
For anybody who wants to know the code that i used is:
Code:
NSString *tempScoreString = [NSString stringWithFormat: @"I just got %@ on myappname !!!", lastScore.text];
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.