Created
September 6, 2013 09:34
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
*\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