Google Docs returns a long 3 line string when supplied with credentials. This is the format SID=stuff... LSID=stuff... Auth=long authorization token
if I have it stored in NSString, what is the best function to trim all the way up to the "=" behind Auth, and keep the rest?
NSData *returnedData = [NSURLConnection sendSynchronousRequest:request returningResponse:theResponse error:NULL];
NSString *newDataString = [[NSString alloc]initWithData:returnedData encoding:NSUTF8StringEncoding];
NSString *authToken = [newDataString ____________];
If it is a three-line string, I assume it is split with newline (
\n
) characters.Hopefully that gets you started. Once you have individual components, you can repeat on the equals (
=
) character, for example.I figured out the answer on my own through the documentation for NSString:
there is a method called -(NSArray *)componentsSeparatedByCharactersInSet:(NSCharacterSet *)separator {
that gives back an array of different strings, separated by an NSCharacterSet.
There is a class method of NSCharacterSet called
+(NSCharacterSet *)newLineCharacterSet {
that will split up a string with the newline symbol into pieces, so each line becomes its own object. Here is how it works:
Now, the object lineArray contains different strings, each one is the start of a new line.
You're welcome!