Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 2.0

  • Loading branch information...
commit db4df122c544e62da78df8477d2dbb151875c269 1 parent c800415
@alexkolson alexkolson authored
View
8 Examples/CocoaApp/AppController.m
@@ -30,6 +30,14 @@ - (void) didRecieveKNSDirectives:(NSArray*)KNSDirectives {
NSLog(@"%@", KNSDirectives);
}
+// another kynetx delegate method
+// this one gets called whe the KNS request fails
+- (void) KNSRequestDidFailWithError:(NSError*)error {
+ // do stuff
+ // in this case, we'll just log the error's localized description
+ // of course you can access any valid NSError properties like localizedRecoveryOptions, domain etc.
+ NSLog(@"SOMETHING HORRIBLY SAD AND BAD AND NOT LEGIT JUST HAPPEND!!!! GAH!!! %@", [error localizedDescription]);
+}
- (void) dealloc {
[super dealloc];
}
View
1  Examples/CocoaApp/Kynetx.h
@@ -14,6 +14,7 @@
@optional
- (void) didRecieveKNSDirectives:(NSArray*)KNSDirectives;
+- (void) KNSRequestDidFailWithError:(NSError*)error;
@end
View
8 Examples/CocoaApp/Kynetx.m
@@ -49,7 +49,7 @@ - (void) signal:(NSString *)name params:(NSDictionary*)params {
[KNSRequest setAllHTTPHeaderFields:headers];
// then use that request to make a connection
// specifying that the current object should act as its delegate
- [[NSURLConnection alloc] initWithRequest:KNSRequest delegate:self];
+ [[[NSURLConnection alloc] initWithRequest:KNSRequest delegate:self] autorelease];
}
- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
@@ -82,6 +82,12 @@ - (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
[[self delegate] didRecieveKNSDirectives:KNSDirectives];
}
+- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError*)error {
+ // something went wrong
+ // call appropriate delegate method
+ [[self delegate] KNSRequestDidFailWithError:error];
+}
+
- (NSArray*) parseDirectives:(NSData*)response {
// parse json string of directives returned from KNS
View
5 README.md
@@ -1,5 +1,2 @@
# Kynetx Objective-C Library
- A Kynetx Objective-C library, v1.0.
-
-## Documentation
- Documentation will be avaliabe when v2.0 is released.
+ A Kynetx Objective-C library, v2.0.
View
1  kynetx.h
@@ -14,6 +14,7 @@
@optional
- (void) didRecieveKNSDirectives:(NSArray*)KNSDirectives;
+- (void) KNSRequestDidFailWithError:(NSError*)error;
@end
View
8 kynetx.m
@@ -49,7 +49,7 @@ - (void) signal:(NSString *)name params:(NSDictionary*)params {
[KNSRequest setAllHTTPHeaderFields:headers];
// then use that request to make a connection
// specifying that the current object should act as its delegate
- [[NSURLConnection alloc] initWithRequest:KNSRequest delegate:self];
+ [[[NSURLConnection alloc] initWithRequest:KNSRequest delegate:self] autorelease];
}
- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
@@ -82,6 +82,12 @@ - (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
[[self delegate] didRecieveKNSDirectives:KNSDirectives];
}
+- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError*)error {
+ // something went wrong
+ // call appropriate delegate method
+ [[self delegate] KNSRequestDidFailWithError:error];
+}
+
- (NSArray*) parseDirectives:(NSData*)response {
// parse json string of directives returned from KNS
Please sign in to comment.
Something went wrong with that request. Please try again.