Sunday, May 3, 2015
Tuesday, April 7, 2015
Objective-C REST API Network Status Codes
Objective-C REST API Network Status Codes
/*!@typedef NS_ENUM (NSUInteger, kStatusInformation)@abstract Informational responses.@discussionThese are valid only in the scope of <Project Name>.*/typedef NS_ENUM(NSInteger, kStatusInformation) {/*!This interim response indicates that everything so far is OKand that the client should continue with the request or ignoreit if it is already finished.*/kStatusInformation_Continue = 100,/*!This code is sent in response to an Upgrade: request header bythe client, and indicates that the protocol the server is switching too.It was introduced to allow migration to an incompatible protocol version,and is not in common use.*/kStatusInformation_SwitchingProtocol = 101,};/*!@typedef NS_ENUM (NSUInteger, kStatusSuccess)@abstract Successful responses.@discussionThese are valid only in the scope of Momentage.*/typedef NS_ENUM(NSInteger, kStatusSuccess) {/*! The request has succeeded. */kStatusSuccess_OK = 200,/*!The request has succeeded and a new resource has beencreated as a result of it.This is typically the response sent after a PUT request.*/kStatusSuccess_Created = 201,/*!The request has been received but not yet acted upon.It is non-committal, meaning that there is no way in HTTP to later sendan asynchronous response indicating the outcome of processing the request.It is intended for cases where another process or server handles the request,or for batch processing.*/kStatusSuccess_Accepted = 202,/*!This response code means returned meta-information set is not exactset as available from the origin server, but collected from a localor a third party copy. Except this condition, 200 OK response shouldbe preferred instead of this response.*/kStatusSuccess_PartialInfo = 203,/*!There is no content to send for this request, but the headers may beuseful. The user-agent may update its cached headers for thisresource with the new ones.*/kStatusSuccess_NoResponse = 204,/*!This response code is sent after accomplishing request to tell useragent reset document view which sent this request.*/kStatusSuccess_RestContent = 205,/*!This response code is used because of range header sent by the clientto separate download into multiple streams.*/kStatusSuccess_PartialContent = 206,/*! */kStatusSuccess_251 = 251,};/*! *//*!@typedef NS_ENUM (NSUInteger, FBErrorCode)@abstract Error codes returned by the Facebook SDK in NSError.@discussionThese are valid only in the scope of FacebookSDKDomain.*/typedef NS_ENUM(NSInteger, APIErrorCode) {APIErrorCodeMultipleChoice = 300};// 4xx Client error/*!@typedef NS_ENUM (NSUInteger, kStatusClientError)@abstract Client error responses@discussionThese are valid only in the scope of Momentage.*/typedef NS_ENUM(NSInteger, kStatusClientError) {/*! */kStatusClientError_BadRequest = 400,/*! */kStatusClientError_Unauthorized = 401,/*! */kStatusClientError_PaymentRequest = 402,/*! */kStatusClientError_Forbidden = 403,/*! */kStatusClientError_NotFound = 404,/*! */kStatusClientError_MethodNotAllowed = 405,kStatusClientError_ExpectationFailed = 417,};// 5xx Server error responses/*!@typedef NS_ENUM (NSUInteger, kStatusServerError)@abstract Client error responses@discussionThese are valid only in the scope of Momentage.*/typedef NS_ENUM(NSInteger, kStatusServerError) {/*! The server has encountered a situation it doesn't know how to handle. */kStatusServerError_InternalError = 500,/*!The request method is not supported by the server and cannot be handled. The onlymethods that servers are required to support (and therefore that must not returnthis code) are GET and HEAD.*/kStatusServerError_NotImplemented = 501,/*!This error response means that the server, while working as a gateway to get aresponse needed to handle the request, got an invalid response.*/kStatusServerError_BadGateway = 502,/*!The server is not ready to handle the request. Common causes are a server that isdown for maintenance or that is overloaded. Note that together with this response,a user-friendly page explaining the problem should be sent. This responses shouldbe used for temporary conditions and the Retry-After: HTTP header should, ifpossible, contain the estimated time before the recovery of the service. Thewebmaster must also take care about the caching-related headers that are sentalong with this response, as these temporary condition responses should usuallynot be cached.*/kStatusServerError_ServiceUnavailable = 503,/*!This error response is given when the server is acting as a gateway and cannot geta response in time.*/kStatusServerError_GatewayTimeout = 504,/*! The HTTP version used in the request is not supported by the server. */kStatusServerError_HTTPVersionNotSupported = 505,};
via -
Github Gist
Other Links -
Thursday, February 26, 2015
Solved : Slow MacBook Pro SSD after Partition problem
Last week I was given new Macbook Pro in my job at Leapfrog Technology
It was the exact same Macbook Pro config laptop I previously had at Leapfrog but there was no such issue like once I pressed power button it would show "Apple" logo and computer would login instantly within 5sec. But my new Mac took around 30sec before showing Apple logo and every time it booted for first time but after that every thing was normal.
So only thing I did after I got the macbook pro was using Disk Utility to make SDD's partition !
So I thought there might be the issue like bios is trying to search for the OS partition and its the timeout of 30sec which lead to boot from next partition.
So all I did was selected the "Startup Disk" from the "System Preferences"
and Rebooted in the system Partition and boom the issue was gone :]
Thursday, December 11, 2014
Ncell brings iPhone in Nepal - iPhone 6, iPhone 6 Plus, iPhone 5s
For the first time in nepal there is officially iPhone !
Yes for the first time in the end of 2014, you can officially buy iPhones from NCell :]

Available in Space Gray, Gold and Silver. All iPhone 6 comes with 1GB data every month for 6 months. To book your iPhone 6, visit Ncell Centres in Kathmandu today.


Avaiable in Space Gray, Gold and SiIver. All iPhone 5S comes with 300MB data every month for 6 months. To book your iPhone 5S, visit your nearest Ncell Centre today.
Yes for the first time in the end of 2014, you can officially buy iPhones from NCell :]
As per todays exchange rate its 1$ = 100Rs,
Hence for US 650$ Sim-Free iPhone means - 65,000 Rs which with tax & vats will be around
70,000 Rs. Where as Ncell gives iPhone for 82,000 Rs is somewhat expensive !
Which is 12,000 Rs more then what you might be expecting but you do get total of 6Gb data free ( 1Gb for 6 months ).
iPhone 6
| Capacity | Total Price | Amount Required for Booking |
| 16GB | Rs. 81,999 | Rs. 10,000 |
| 64GB | Rs. 92, 499 | |
| 128GB | Rs. 104,999 |
Available in Space Gray, Gold and Silver. All iPhone 6 comes with 1GB data every month for 6 months. To book your iPhone 6, visit Ncell Centres in Kathmandu today.
iPhone 6 Plus
| Capacity | Total Price | Amount Required for Booking |
| 16GB | Rs. 92,499 | Rs. 12,000 |
| 64GB | Rs. 104,999 | |
| 128GB | Rs. 117,99 |
Available in Space Gray, Gold and Silver. All iPhone 6 Plus comes with 1GB data every month for 6 months. To book your iPhone 6 Plus, visit your nearest Ncell Centre today.
iPhone 5s
| Capacity | Total Price | Amount Required for Booking |
| 16GB | Rs. 67,199 | Rs. 8,000 |
| 32GB | Rs. 73,999 |
Links -
Tuesday, November 4, 2014
Getting Started With Static and Dynamic Libraries for iOS and CocoaPods
Sources -
http://www.raywenderlich.com/41377/creating-a-static-library-in-ios-tutorial
https://developer.apple.com/library/ios/technotes/iOSStaticLibraries/Articles/configuration.html#//apple_ref/doc/uid/TP40012554-CH3-SW1
http://wiki.remobjects.com/wiki/WIP:How_to_link_Custom_Static_Libraries_from_your_Xcode_Projects
http://www.slideshare.net/sigmapoint/2014-0324-building-static-libraries-for-i-os-with-cocoapods
http://pdx.esri.com/blog/2013/12/13/namespacing-dependencies/
http://blog.db-in.com/universal-framework-for-ios/
https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/OverviewOfDynamicLibraries.html
https://github.com/jverkoey/iOS-Framework#first_parties
http://guides.cocoapods.org/using/using-cocoapods.html
Wednesday, October 22, 2014
iPad Air 2 vs iPad Mini 3 Which iPad to buy or not to buy
This year selecting Apple product isn't as easy as it used to be.
The price matrix is not as simple, actually its quite complex !
To make things easy I have made a simple chart which shows which
is the iPad you should get and which is the iPad you should NOT !
From the matrix its clear if you don't have much money to spend iPad Mini 2, 16Gb is the best options for $299, but if you can afford to spend some cash on iPad, then iPad Air 2, 62Gb should be your option for $599.
Only make sure you don't end up buying iPad mini at $249 for its low price ! Its a two year old A5 chip inside and non-retina display ! Also there is a sad news - iPad mini 3 has no processor update in new model and hence carry the same A7 chip.
The price matrix is not as simple, actually its quite complex !
To make things easy I have made a simple chart which shows which
is the iPad you should get and which is the iPad you should NOT !
From the matrix its clear if you don't have much money to spend iPad Mini 2, 16Gb is the best options for $299, but if you can afford to spend some cash on iPad, then iPad Air 2, 62Gb should be your option for $599.
Only make sure you don't end up buying iPad mini at $249 for its low price ! Its a two year old A5 chip inside and non-retina display ! Also there is a sad news - iPad mini 3 has no processor update in new model and hence carry the same A7 chip.
Sources :
Labels:
a7,
a8x,
comparison,
ipad,
ipad air,
ipad air2,
ipad mini,
ipad mini2,
ipad mini3,
price
Monday, August 11, 2014
Post UIImage on Fan Page as Admin using Facebook iOS SDK - GraphPath, FBRequestConnection, ALAsset
// Model
// FBPagesModel.h
@interface FBPagesModel : NSObject
@property (nonatomic, strong) NSString *access_token;
@property (nonatomic, strong) NSString *category;
@property (nonatomic, strong) NSString *pageId;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSArray *perms;
- (id)initWithDictionary:(NSDictionary *)dictionary;
// FBPagesModel.m
#import "FBPagesModel.h"
@implementation FBPagesModel
- (id)initWithDictionary:(NSDictionary *)dictionary {
if (self = [super init]) {
self.access_token = [dictionary objectForKey:@"access_token"];
self.category = [dictionary objectForKey:@"category"];
self.pageId = [dictionary objectForKey:@"id"];
self.name = [dictionary objectForKey:@"name"];
}
return self;
}
@end
// Uploader
FBPagesModel *pageModel = ....
Facebook *fb = [Facebook new];
[fb setAccessToken:pageModel.access_token];
ALAsset *asset = ... // localMedia asset;
UIImage *largeImage = [self imageForAsset:asset];
// Capture a photo via file upload as multipart/form-data then use the source parameter:
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
largeImage, @"source", nil];
NSLog(@"Params -> \n %@", params);
/* make the API call */
NSString *graphPath = [NSString stringWithFormat:@"/%@/photos", pageModel.pageId];
[FBRequestConnection startWithGraphPath:graphPath
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
/* handle the result */
if (!error) {
NSLog(@"Uploaded to Page \n %@", result);
} else {
NSLog(@"Error posing on FB page \n %@", error);
}
}];
- (UIImage *)imageForAsset:(ALAsset*)asset {
ALAssetRepresentation * representation = [asset defaultRepresentation];
CGImageRef image = [representation fullResolutionImage];
UIImageOrientation orientation = (UIImageOrientation)[representation orientation];
CGFloat scale = [representation scale];
return [UIImage imageWithCGImage:image scale:scale orientation:orientation];
}
Subscribe to:
Comments (Atom)








