📜 ⬆️ ⬇️

Hide and Seek: Code Generation vs. JSON

It is terrible to think, but some ten years ago the development of the system of the most reliable RPC was a whole celebration in the life of a developer. Painful and long holiday, like a wedding for a horse: head in flowers, ass in soap. It was terribly exciting and at the same time incredibly fast. One choice of protocol was worth it. I'm not talking about the fight against the powerful and monstrous frameworks, such as DCOM or CORBA. The implementation of the transport level was generally a lot of people with long beards.

In our happy time, the life of an iOS programmer should be easy and pleasant. Transport has long ceased to be a problem. And the RPC? Easy: we get Apache Thrift from the holster or at the very least Google Protocol Buffers and please, with a minimum of brain voltage, both the protocol and the server and the client are ready. An overwhelming number of applications in the AppStore need only that: a simple and clear interface to remote procedures, preferably in pleasant wrappers from native classes, and the same simple and clear error handling. Everything.

But. Unfortunately, both Thrift and Protobuf are sharpened by the simultaneous development of the client and server. And such luck happens in the programmer’s career not often. Basically, we have to deal with a pile of a long time ago written and given to us in the sensations of network resources, each of which wants to communicate with the outside world in its own unique manner. Of course, everything is not as bad as ten years ago, and often all server-side wishes are reduced to REST + JSON in small variations. But even at this de facto standardization, it hurts to see a man spoiled by Thrift. No typing, a solid string comparison, resulting in tons of the same type of code with tedious uniform checks. Of course, the problem was recognized long ago, and for many languages, for example, there is a zoo of tools for transparently converting JSON into native objects. For Objective-C, of ​​course, there is a RestKit combine, but it relies on introspection and maps all structures in runtime. Again, setting such a dynamic mapping is far from finesse for my taste. The rest of the libraries and utilities I tried for real life were even worse. For example, some JsonPack with its cookie cutters in the browser is difficult to build into a continuous assembly.
')
I chose a tool for the new i-Free project, in which I expected five different heterogeneous REST-like services, both my own and external ones, each with a bunch of methods, brood of broken-down structures and other interesting details. The idea of ​​the need to manually parse dictionaries was unbearable. As the anticipation of refactoring after the inevitable changes in the protocols. Life is too short to take an uninteresting job, so it's better to lose a day, then fly in five minutes. Three days later, the first version of ifacegen already generated code, naive, but plenty.

What is ifacegen?

This is a simple console tool (python script) that generates Objective-C classes from simple IDL, which is as close as possible to the original JSON protocol. These classes transparently repack their state in JSON and back. In addition, ifacegen can generate wrapper classes for transparently invoking remote service methods.

What is it for?

ifacegen works like thrift the other way around. It allows you to take an existing REST + JSON API and pull on it to match the corresponding Objective-C classes to JSON structures and REST methods. In the program, you manipulate only calls to methods of natural types of language, and the generated code hides all unnecessary details.

What exactly is it not useful for?

ifacegen is definitely not suitable for serializing arbitrary classes in JSON and creating classes from any JSON on the fly. No runtime, only compile-time, only hardcore. No NSCoder. And no other languages ​​except Objective-C.

How complex can the protocol be?

Pretty complicated. ifacegen digests nested dictionaries, arrays, including arrays of dictionaries (dictionaries with arrays, well, you understand). Dictionaries are converted into classes, dictionary elements are converted into fields (@property) of classes. IDL supports the description of the atomic element types: int32, int64, double, string, bool, raw and rawstr. raw is an arbitrary dictionary, directly copied into a field of type NSDictionary, rawstr is also an arbitrary dictionary, but encoded into a string like this: "{\"weird\":42,\"str\":\"yes\"}" .

How easy is that?

IDL syntax follows data as closely as possible (and yes, the description language is itself a full-featured JSON). For an example, let's go to the Google Places API. Here is how its documentation describes the geo-point in the responses of the service:
 "geometry" : { "location" : { "lat" : -33.8583790, "lng" : 151.2100270 } } 

ifacegen IDL, which describes this structure, should literally repeat it (field names and their nesting should be the same), adding a bit of markup for convenience. Fields with the names “id” and “void" or starting with the lines “new”, “alloc”, “copy” and “mutableCopy” will automatically receive the “the” prefix so as not to interfere with the ads in the code. All ads are placed in an array with the heading “Iface”:
 {"iface": [ { "struct":"GoogleGeometry", "typedef" : { "location" : { "lat" : "double", "lng" : "double" } } } } 

It's about time for easy code generation. Assuming we put the IDL ads in GoogleClient.json, it will look like this:
 $ python ifacegen.py GoogleClient.json 

As a result, we get two files: GoogleClient.h and GoogleClient.m. The header will contain the declarations of the interfaces of the generated structures:
 @interface GoogleGeometryLocation: NSObject @property (nonatomic) double_t lat; @property (nonatomic) double_t lng; @end; @interface GoogleGeometry: NSObject - (NSData*)dumpWithError:(NSError* __autoreleasing*)error; - (id)initWithLocation:(GoogleGeometryLocation*)location; - (id)initWithDictionary:(NSDictionary*)dictionary error:(NSError* __autoreleasing*)error; - (id)initWithJSONData:(NSData*)jsonData error:(NSError* __autoreleasing*)error; @property (nonatomic) GoogleGeometryLocation* location; @end; 

For all nested dictionaries, simple classes will also be generated. But only the top-level structures will have their own serialization / deserialization methods, otherwise the generator code swells up a lot. Of course, a nested dictionary can also be described by a separate structure with an arbitrary name. Now, wherever this JSON fragment occurs, we can simply insert its name:

 { "struct":"GoogleLocation", "typedef" : { "lat" : "double", "lng" : "double" } }, { "struct":"GoogleGeometry", "typedef" : { "location" : "GoogleLocation" } } 

Inheritance of structures thus declared is supported. For example, if you suddenly need to describe an extended version of GoogleLocation, it will not necessarily repeat all of its fields, it’s enough to follow:
 { "struct":"GoogleLocationEx", "extends": "GoogleLocation", "typedef" : { "elv" : "double" } } 

You can even import types declared in an external module. These modules are searched in the same directory as the original one. By the way, there will be no code generation when importing; types will simply be sucked in.
 {"iface": [ { "import": "OtherModule.json" } ... 


Ok, these are structures. And what about the challenges?

Again we go to the Google Places API. Take a simple call: request location data . It has a URL like this:
maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
  maps.googleapis.com/maps/api/place/details/json? 
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
  maps.googleapis.com/maps/api/place/details/json? 
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
  maps.googleapis.com/maps/api/place/details/json? 
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
  maps.googleapis.com/maps/api/place/details/json? 
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git

maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git

maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
  maps.googleapis.com/maps/api/place/details/json? 
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
  maps.googleapis.com/maps/api/place/details/json? 
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
  maps.googleapis.com/maps/api/place/details/json? 
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git

maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git

maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git

maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git

maps.googleapis.com/maps/api/place/details/json?
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git
  maps.googleapis.com/maps/api/place/details/json? 
, , JSON. GoogleDetailsResult , :
{ "procedure": "placeDetails", "prefix": "place/details/json", "prerequest": { "key":"string", "reference": "string", "sensor": "string", "language": "string" }, "request" : {}, "response": "GoogleDetailsResult" }

prefix , . prerequest , URL ( RFC 3986 ), request JSON, . . . «» ( ):
- (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error;
:
GoogleDetailsResult* result = [self.google placeDetailsWithKey:key andReference:ref andSensor:@"true" andLanguage:locale andError:&error];

Objective-C : GoogleClient.m - (GoogleDetailsResult*)placeDetailsWithKey:(NSString*)key andReference:(NSString*)reference andSensor:(NSString*)sensor andLanguage:(NSString*)language andError:(NSError* __autoreleasing*)error { id tmp; [transport setRequestParams:@{ @"key" : NULLABLE(key), @"reference" : NULLABLE(reference), @"sensor" : NULLABLE(sensor), @"language" : NULLABLE(language) }]; if ( ![transport writeAll:nil prefix:@"/place/details/json" error:error] ) { return nil; } NSData* outputData = [transport readAll]; if ( outputData == nil ) { return nil; } NSDictionary* output = [NSJSONSerialization JSONObjectWithData:outputData options:NSJSONReadingAllowFragments error:error]; if ( *error != nil ) { return nil; } GoogleDetailsResult* GoogleDetailsResult235; GoogleDetailsResult235 = [GoogleDetailsResult new]; GooglePlaceDetails* GooglePlaceDetails236; NSDictionary* outputResult237 = [output objectForKey:@"result"]; if ( outputResult237 != nil && ![outputResult237 isEqual:[NSNull null]]) { GooglePlaceDetails236 = [GooglePlaceDetails new]; NSArray* outputResult237Address_components238 = [outputResult237 objectForKey:@"address_components"]; NSMutableArray* address_components4; if ( outputResult237Address_components238 != nil && ![outputResult237Address_components238 isEqual:[NSNull null]]) { address_components4 = [NSMutableArray arrayWithCapacity:[outputResult237Address_components238 count]]; for ( id item in outputResult237Address_components238) { GoogleAddressComponent* GoogleAddressComponent239; GoogleAddressComponent239 = [GoogleAddressComponent new]; GoogleAddressComponent239.longName = ( tmp = [item objectForKey:@"long_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); GoogleAddressComponent239.shortName = ( tmp = [item objectForKey:@"short_name"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); NSArray* itemTypes240 = [item objectForKey:@"types"]; NSMutableArray* types7; if ( itemTypes240 != nil && ![itemTypes240 isEqual:[NSNull null]]) { types7 = [NSMutableArray arrayWithCapacity:[itemTypes240 count]]; for ( id item in itemTypes240) { [types7 addObject:item]; } } GoogleAddressComponent239.types = types7; [address_components4 addObject:GoogleAddressComponent239]; } } GooglePlaceDetails236.addressComponents = address_components4; // ... GoogleDetailsResult235.result = GooglePlaceDetails236; GoogleDetailsResult235.status = ( tmp = [output objectForKey:@"status"], [tmp isEqual:[NSNull null]] ? nil : (NSString*)tmp ); return GoogleDetailsResult235; }


? . , IFTransport:
@protocol IFTransport - (void)setRequestParams:(NSDictionary*)params; - (BOOL)writeAll:(NSData*)data prefix:(NSString*)prefix error:(NSError* __autoreleasing*)error; - (NSData*)readAll; @end
IFHTTPTransport, NSURLConnection HTTP(S). JSON-, POST. — GET. HTTP 200 202 , NSError . URL- -, IFHTTPTransport (Protected). :
- (NSMutableURLRequest*)prepareRequestWithURL:(NSURL*)url data:(NSData*)data; - (NSString*)buildRequestParamsString:(NSDictionary*)requestParams; - (BOOL)shouldBreakOnError:(NSError*)error;

IFTransport . . , , . , , .

RPC- :
NSURL* googleURL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api"]; id<IFTransport> transport = [[IFHTTPTransport alloc] initWithURL:googleURL]; self.google = [[google alloc] initWithTransport:transport];

? , , . : -, ARC, . -, NSJSONSerialization, . , ifacegen . , python , .

: , , . . , . , , .

: prerequest "string" , . , . IDL, -.

? Bitbucket. IDL. .
$ git clone https://bitbucket.org/ifreefree/ifacegen.git

Source: https://habr.com/ru/post/213697/


All Articles