0

I am getting userid through parsing a link.Again i have to parse it with userid to get the access. What i am doing

NSString *str=[[NSString alloc]initWithFormat:@"http://abc.com/fb_redirect_mobile/?accessToken=4546"];

This gives me the userid,now i want to use that userid to parse it again such as:

NSString *str=[[NSString alloc]initWithFormat:@"http://abc.com/user/userid/bookmarks"]; 

In other languages I have seen they are just using:

NSString *str=[[NSString alloc]initWithFormat:@"http://abc.com/user/"+userid+"/bookmarks"];

The userid variable takes user id.how i can do this in iPhone.I know my question is lengthy but i tried to make it clear what i want.please help..please also tell me how to store a parsing id into string,such as userid i am going to get after parsing the url./now how i can save it in form of string.

5 Answers 5

2
NSString *userId = @"123456";
NSString *str=[[NSString alloc]initWithFormat:@"http://abc.com/user/%@/bookmarks", userId];

initWithFormat:/stringWithFormat: follow the general format convention set by printf/scanf

Sign up to request clarification or add additional context in comments.

1 Comment

In my camera app when i clicks the image its going to be saved but i want before getting saved it will ask user for title and description for image.How i can do this?? Please help..
2

The way you concatenated your userid is not valid syntax in Obj-C

NSString *str=[[NSString alloc]initWithFormat:@"http://abc.com/user/"+userid+"/bookmarks"];

What you'd probably want to do is use a format specifier for an Obj-C object (in your case NSString), and use that within your URL (assuming userid is an NSString, which it probably is. If it's a C based string, use %s as your format specifier instead).

NSString *str=[[NSString alloc]initWithFormat:@"http://abc.com/user/%@/bookmarks", userid];

Refer to these on how to use stringWithFormat: on an NSString:

1 Comment

In my camera app when i clicks the image its going to be saved but i want before getting saved it will ask user for title and description for image.How i can do this?? Please help..
1

you can give like this,

NSString *str=[NSString stringWithFormat:@"http://abc.com/user/%@/bookmarks",userid];

Comments

1

Instead of

NSString *str=[[NSString alloc]initWithFormat:@"http://abc.com/user/"+userid+"/bookmarks"];

You would use

NSString *str=[[NSString alloc] initWithFormat:@"http://abc.com/user/%@/bookmarks",userid];

1 Comment

In my camera app when i clicks the image its going to be saved but i want before getting saved it will ask user for title and description for image.How i can do this?? Please help..
0

Well you almost got it:

NSString *usrid = @"4546";
NSString *str=[NSString stringWithFormat:@"http://abc.com/fb_redirect_mobile/?accessToken=%@", userid];

You can use the stringWithFormat: method of NSString for this.

7 Comments

Thanks a lot...can you tell me i am getting userid from the json parsing...then how to store it into a variable..
Not really since I don't know how the JSON looks like or you code. I suggest you pick up a book about Objective-C development, these question are really simple.
@deepak This will be another question, as it's on an entirely different topic
I am new to iPhone.so,i dont know many thing about it..thanks for supporting me..
@rckoenes In my camera app when i clicks the image its going to be saved but i want before getting saved it will ask user for title and description for image.How i can do this?? Please help..
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.