Skip to content

Instantly share code, notes, and snippets.

@pablocarrillo
Created September 6, 2013 09:34
Show Gist options
  • Save pablocarrillo/6461612 to your computer and use it in GitHub Desktop.
Save pablocarrillo/6461612 to your computer and use it in GitHub Desktop.
String serializer to change between parameters on array to coma separated string on HTML address
/*!
*\brief Method to serialize arrays
* This method serialized elements from an array an fill the space with the urlcode for querys
*\param array an array of nsstrings to be serialized
*\return NSString* a string with all the elements on the array serialized
*/
+ (NSString*)stringSerializerForQuery:(NSArray*)array{
NSMutableString *returnString;
for (NSString* stringOnArray in array) {
if (!returnString) {
returnString= [NSMutableString new];
NSString * newString = [stringOnArray stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
[returnString appendString:newString];
}else{
NSString * newString = [stringOnArray stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
[returnString appendFormat:@",%@",newString];
}
}
return returnString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment