Friday 31 July 2015

'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.

After every pod install I select the pod-afnetworking target and change the APPLICATION_EXTENSION_API_ONLY back to NO. It's a bit annoying but right now the only way how to 

Wednesday 24 July 2013

Download an Image and Save it as PNG or JPEG in iPhone SDK

 NSLog(@"Downloading...");
 // Get an image from the URL below
 UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.objectgraph.com/images/og_logo.png"]]];
 
 NSLog(@"%f,%f",image.size.width,image.size.height);
 
 // Let's save the file into Document folder.
 // You can also change this to your desktop for testing. (e.g. /Users/kiichi/Desktop/)
 // NSString *deskTopDir = @"/Users/kiichi/Desktop";
 
 NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
 
 // If you go to the folder below, you will find those pictures
 NSLog(@"%@",docDir);
 
 NSLog(@"saving png");
 NSString *pngFilePath = [NSString stringWithFormat:@"%@/test.png",docDir];
 NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(image)];
 [data1 writeToFile:pngFilePath atomically:YES];
 
 NSLog(@"saving jpeg");
 NSString *jpegFilePath = [NSString stringWithFormat:@"%@/test.jpeg",docDir];
 NSData *data2 = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0f)];//1.0f = 100% quality
 [data2 writeToFile:jpegFilePath atomically:YES];
 
 NSLog(@"saving image done");
 
 [image release];


Download Source code:here

ads: ebay

Wednesday 17 July 2013

How to set UITextField Resign First responder ?

First of all assign UITextFieldDelegate in .h file Like this


@interface ViewController : UIViewController<UITextFieldDelegate>

Propertize textfield in .h file

@property (nonatomic, unsafe_unretained) IBOutlet UITextField * txtField;

Assign Delegate in viewDidLoad in .m file

self. txtField.delegate = self;

Add this Method in .m file

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if(textField==selftxtField )
    {
        [self. txtField resignFirstResponder];
        return NO;
    }
    return YES;
}
Ads: ebay

Understanding the ASIHTTPRequest authentication process

HTTP Authentication is one area where ASIHTTPRequest has had a fair number of changes recently. It can be difficult to understand how where credentials come from, and when they are applied and sent to the server.
Credentials for authentication can come from several places:
  • the usernamepassword and domain (NTLM only) properties of a request
  • The url (eg: http://ben:copsey@allseeing-i.com)
  • The session store (a list of credentials that have been used before in the same application session)
  • The keychain. On Mac OS X, ASIHTTPRequest can use credentials stored by other applications, if the user agrees to allow access. On iPhone OS, ASIHTTPRequest can only read credentials that were stored by the same application.
  • Request delegates that respond to authenticationNeededForRequest: can set credentials on the request when this method is called
  • ASIAuthentication dialogs (when shouldPresentAuthenticationDialog is true)
Credentials can be applied to a request in two ways:
  1. Before a request is sent
    When shouldPresentCredentialsBeforeChallenge is true, as is the default, requests can build an authorization header and apply it to the request before it is sent. The header is added only when the username or password properties are set on the request, or there are credentials requests that have previously used to talk to the same server in the session store. If a username and password are set on the request, ASIHTTPRequest can only create a basic authentication Authorization header, NTLM and Digest are not supported.
  2. After a challenge from the server
    If no credentials or the wrong credentials are sent to the server, it may respond with a 401 status code. ASIHTTPRequest will then attempt to find credentials it can use to resend the request.
Download PDF How its work:Here


Reference From:http://allseeing-i.com/
ads: ebay

Monday 8 July 2013

Failed to Attach to Process ID Xcode

iOS Simulator>Reset Content and Setting..>Reset  

  hope u can Fix this issue

ads: ebay

Go to your Application using Terminal

cd ../../Applications would take you toMacintosh HD/Applications

ads: ebay

Monday 10 June 2013

supportedInterfaceOrientations method not working on iOS 6 UIViewController

You Should Change in adding the viewController

Replace this code 

[window addSubview:viewController.view];

by this line:

[window setRootViewController:viewController]; 

ads: ebay