以下将创建一个未保留的NSMutableString
:
NSMutableString *webServiceLinkWithResponses = [NSMutableString stringWithFormat:@"http://lmsstaging.2xprime.com/services/ParticipantService.cfc?method=setVideoExamResults&student_id=10082&course_id=VRT_TRA&lesson=904&examtype=r&question_num=%@&ansValue=%@", stringOne, stringTwo];
如果您需要保留它,只需使用[[NSMutableString alloc] initWithFormat:@"..."]
:
NSMutableString *webServiceLinkWithResponses = [[NSMutableString alloc] initWithFormat:@"http://lmsstaging.2xprime.com/services/ParticipantService.cfc?method=setVideoExamResults&student_id=10082&course_id=VRT_TRA&lesson=904&examtype=r&question_num=%@&ansValue=%@", stringOne, stringTwo];
你真的需要它是一个可变的字符串,一旦它被创建,你会改变它吗?如果不是简单地将 更改NSMutableString
为NSString
,例如(这将返回一个 autoreleased NSString
,[NSString alloc] initWithFormat:]
如果需要保留它,请使用):
NSString *webServiceLinkWithResponses = [NSString stringWithFormat:@"http://lmsstaging.2xprime.com/services/ParticipantService.cfc?method=setVideoExamResults&student_id=10082&course_id=VRT_TRA&lesson=904&examtype=r&question_num=%@&ansValue=%@", stringOne, stringTwo];