Skip to content

Commit

Permalink
Changed podspec to new version with XMLString methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyguitar committed Aug 1, 2013
1 parent 47297c0 commit 872077e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Demos/WeatherXMLDemo/WeatherXMLDemo/NSObject+ObjectMap.h
Expand Up @@ -60,7 +60,9 @@

// XML-SOAP
-(NSData *)XMLData;
-(NSString *)XMLString;
-(NSData *)SOAPData;
-(NSString *)SOAPString;

// For mapping an array to properties
-(NSMutableDictionary *)getPropertyArrayMap;
Expand Down
46 changes: 27 additions & 19 deletions Demos/WeatherXMLDemo/WeatherXMLDemo/NSObject+ObjectMap.m
Expand Up @@ -640,19 +640,31 @@ +(NSString *)dateForObject:(id)obj{
return [formatter stringFromDate:date];
}

#pragma mark - SOAP/XML Serialization
#pragma mark - XML/SOAP Serialization

-(NSData *)XMLData{
NSDictionary *dict = [NSObject dictionaryWithPropertiesOfObject:self];
NSString *xmlString = [self xmlStringFromDictionary:dict];
return [xmlString dataUsingEncoding:NSUTF8StringEncoding];
}

-(NSString *)XMLString{
NSDictionary *dict = [NSObject dictionaryWithPropertiesOfObject:self];
return [self xmlStringFromDictionary:dict];
}

-(NSData *)SOAPData{
NSDictionary *dict = [NSObject dictionaryWithPropertiesOfObject:self];
return [self soapDataFroDictionary:dict];
NSString *soapString = [self soapStringFromDictionary:dict];
return [soapString dataUsingEncoding:NSUTF8StringEncoding];
}

-(NSData *)XMLData{
-(NSString *)SOAPString{
NSDictionary *dict = [NSObject dictionaryWithPropertiesOfObject:self];
return [self xmlDataForDictionary:dict];
return [self soapStringFromDictionary:dict];
}

-(NSData *)soapDataFroDictionary:(NSDictionary *)dict{
-(NSString *)soapStringFromDictionary:(NSDictionary *)dict{
SOAPObject *soapObject = (SOAPObject *)self;

NSMutableString *soapString = [[NSMutableString alloc] initWithString:@""];
Expand Down Expand Up @@ -685,12 +697,8 @@ -(NSData *)soapDataFroDictionary:(NSDictionary *)dict{
[soapString appendFormat:@"</%s>", class_getName([soapObject.Header class])];
[soapString appendString:@"</soap:Header>"];
}



}


if ([dict valueForKey:@"Body"]) {
[soapString appendString:@"<soap:Body>"];

Expand Down Expand Up @@ -719,29 +727,29 @@ -(NSData *)soapDataFroDictionary:(NSDictionary *)dict{
//Close Envelope
[soapString appendString:@"</soap:Envelope>"];

return [soapString dataUsingEncoding:NSUTF8StringEncoding];
return soapString;
}

-(NSData *)xmlDataForDictionary:(NSDictionary *)dict{
NSMutableString *soapString = [[NSMutableString alloc] initWithString:@""];
-(NSString *)xmlStringFromDictionary:(NSDictionary *)dict{
NSMutableString *xmlString = [[NSMutableString alloc] initWithString:@""];

//Document Header
[soapString appendString:@"<?xml version=\"1.0\"?>"];
[xmlString appendString:@"<?xml version=\"1.0\"?>"];

//Append containing class name
[soapString appendFormat:@"<%s>", class_getName([self class])];
[xmlString appendFormat:@"<%s>", class_getName([self class])];

//Fill in all values
for (id key in dict) {
[soapString appendFormat:@"<%@>", (NSString *)key];
[soapString appendFormat:@"%@", [self xmlStringForDictionary:dict key:key]];
[soapString appendFormat:@"</%@>", (NSString *)key];
[xmlString appendFormat:@"<%@>", (NSString *)key];
[xmlString appendFormat:@"%@", [self xmlStringForDictionary:dict key:key]];
[xmlString appendFormat:@"</%@>", (NSString *)key];
}

//Close containing class name
[soapString appendFormat:@"</%s>", class_getName([self class])];
[xmlString appendFormat:@"</%s>", class_getName([self class])];

return [soapString dataUsingEncoding:NSUTF8StringEncoding];
return xmlString;
}


Expand Down
4 changes: 2 additions & 2 deletions NSObject-ObjectMap.podspec
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = "NSObject-ObjectMap"
s.version = "1.0.0"
s.version = "1.0.1"
s.summary = "This is a drop-in category of NSObject that makes it easy to initialize custom objects from JSON or XML."
s.homepage = "https://github.com/uacaps/NSObject-ObjectMap"
s.license = { :type => 'UA', :file => 'LICENSE' }
s.author = { "uacaps" => "care@cs.ua.edu" }
s.source = { :git => "https://github.com/uacaps/NSObject-ObjectMap.git", :tag => "1.0.0" }
s.source = { :git => "https://github.com/uacaps/NSObject-ObjectMap.git", :tag => "1.0.1" }
s.platform = :ios, '5.0'
s.source_files = 'NSObject-ObjectMap/*.{h,m}'
s.requires_arc = true
Expand Down

0 comments on commit 872077e

Please sign in to comment.