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.
@discussion
These are valid only in the scope of <Project Name>.
*/
typedef NS_ENUM(NSInteger, kStatusInformation) {
/*!
This interim response indicates that everything so far is OK
and that the client should continue with the request or ignore
it if it is already finished.
*/
kStatusInformation_Continue = 100,
/*!
This code is sent in response to an Upgrade: request header by
the 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.
@discussion
These 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 been
created 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 send
an 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 exact
set as available from the origin server, but collected from a local
or a third party copy. Except this condition, 200 OK response should
be preferred instead of this response.
*/
kStatusSuccess_PartialInfo = 203,
/*!
There is no content to send for this request, but the headers may be
useful. The user-agent may update its cached headers for this
resource with the new ones.
*/
kStatusSuccess_NoResponse = 204,
/*!
This response code is sent after accomplishing request to tell user
agent reset document view which sent this request.
*/
kStatusSuccess_RestContent = 205,
/*!
This response code is used because of range header sent by the client
to 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.
@discussion
These 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
@discussion
These 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
@discussion
These 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 only
methods that servers are required to support (and therefore that must not return
this code) are GET and HEAD.
*/
kStatusServerError_NotImplemented = 501,
/*!
This error response means that the server, while working as a gateway to get a
response 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 is
down for maintenance or that is overloaded. Note that together with this response,
a user-friendly page explaining the problem should be sent. This responses should
be used for temporary conditions and the Retry-After: HTTP header should, if
possible, contain the estimated time before the recovery of the service. The
webmaster must also take care about the caching-related headers that are sent
along with this response, as these temporary condition responses should usually
not be cached.
*/
kStatusServerError_ServiceUnavailable = 503,
/*!
This error response is given when the server is acting as a gateway and cannot get
a 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 :]

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



CapacityTotal PriceAmount Required for Booking
16GBRs. 81,999Rs. 10,000
64GBRs. 92, 499
128GBRs. 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




CapacityTotal PriceAmount Required for Booking
16GBRs. 92,499Rs. 12,000
64GBRs. 104,999
128GBRs. 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


CapacityTotal PriceAmount Required for Booking
16GBRs. 67,199Rs. 8,000
32GBRs. 73,999
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.

Links - 



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.



Sources : 



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];

}

Thursday, March 27, 2014

Microsoft office 365 - Word, Excel, Powerpoint for iPad - for FREE


History

History repeats its self .... lets move back to 1997 !



Steve Jobs, Bill Gates and the Microsoft Deal (1997)


Things changed when Steve Jobs came back at Apple in 1997. On the brink of bankruptcy, Jobs turned to his ‘old acquaintance’ Bill Gates for help.The Microsoft Deal is considered a low point in Apple’s history by many.When Steve Jobs announced that Microsoft was not the enemy anymore, few could believe their ears. He went as far as praising the quality of their Mac apps like Office and Internet Explorer… that was outrageous!Things were weird for a few years – 5 years to be exact. Which corresponds to the 5 years of the ‘Microsoft Deal’. During that period Steve Jobs only had good things to say about Redmond.

Announcement


And today Microsoft did announced Office for iPad !
http://blogs.office.com/2014/03/27/announcing-the-office-you-love-now-on-the-ipad/

But in 2014 its through Tweet where we can see there relation :]



Get it for FREE !

Yes you read it right, you can still get it for free



https://www.facebook.com/MicrosoftStore/photos/a.160861237479.117183.150915932479/10152279411957480/?type=1&permPage=1
Yes its free but ...  as you have read - "Office 365 is here for the iPad.® The first 50 people to bring their iPad in-store starting Friday 3/28 will get Office 365 free for 1 year" !

App Preview

Microsoft office, already featured and top in app store.



Microsoft Word for iPad




Microsoft Excel for iPad


Microsoft PowerPoint for iPad




Other Alternative