Tuesday 1 March 2016

NSURLSession/NSURLConnection HTTP load failed on iOS 9

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>yourserver.com</key>
    <dict>
      <!--Include to allow subdomains-->
      <key>NSIncludesSubdomains</key>
      <true/>
      <!--Include to allow insecure HTTP requests-->
      <key>NSExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <!--Include to specify minimum TLS version-->
      <key>NSExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
    </dict>
  </dict>
</dict>
 
============================================================
 

Saturday 27 February 2016

how to use AFNetworking Using Post IOS 9 Iphone

NSURL *URL = [NSURL URLWithString:@"http://example.com"];
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:URL];
[manager GET:@"/resources" parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
    [resources addObjectsFromArray:responseObject[@"resources"]];

    [manager SUBSCRIBE:@"/resources" usingBlock:^(NSArray *operations, NSError *error) {
        for (AFJSONPatchOperation *operation in operations) {
            switch (operation.type) {
                case AFJSONAddOperationType:
                    [resources addObject:operation.value];
                    break;
                default:
                    break;
            }
        }
    } error:nil];
} failure:nil];

=======>

Link of Reference:
http://nshipster.com/afnetworking-2/
===> Class Of AFnetworking:-
https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-2.0-Migration-Guide

how to get and change value of slider stepper Ios/iphone

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.slider.minimumValue = 0;
    self.slider.maximumValue = 100;

    self.stepper.minimumValue = 0;
    self.stepper.maximumValue = 100;
    self.stepper.stepValue = 1;

    self.slider.value = 10;
    self.stepper.value = 10;

}

- (IBAction)stepperValueChanged:(UIStepper *)sender {

    [self.slider setValue:sender.value];

    self.myTextLabel.text = [@((int)sender.value) stringValue];

}

- (IBAction)sliderValueChanged:(UISlider *)sender {

    [self.stepper setValue:sender.value];

    self.myTextLabel.text = [@((int)sender.value) stringValue];
}

Thursday 25 February 2016

How to Get Data Using WebSerIvice IOS 9 With Plst Setting Ios/Iphone

======================================================= <key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>test.testdomain.com</key>
    <dict>
      <key>NSIncludesSubdomains</key>
      <true/>
      <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
      <false/>
 </dict>

======================================================
NSMutableArray *searchResults =[[NSMutableArray alloc]init];
   
 
  NSString *strURL = @"http://google.com";
 

  NSURL *URL = [NSURL URLWithString:[[NSString stringWithFormat:@"%@", strURL]
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];

   NSURLRequest *request = [NSURLRequest requestWithURL:URL];
   
NSURLSession *session = [NSURLSession sharedSession];
  
 NSURLSessionDataTask *task = [session dataTaskWithRequest:request
      
                      completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error)

{
                                      dict= [NSJSONSerialization JSONObjectWithData:data

   

                                                                       options:kNilOptions
                                                                              error:&error];
                                     
                                      keyArray = [dict objectForKey:@"videos"];
                                      NSLog(@"response: %@", recipes);
                                      [tblvw reloadData];
                                
 }];
   
  
 [task resume];

how to Set Edges and TableView Frame Hight IOS/Iphone

=> =================================================
  self.edgesForExtendedLayout=UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars=NO;
    self.automaticallyAdjustsScrollViewInsets=NO;
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil] ;


======================================================
 CGRect frame = tblvw.tableHeaderView.frame;
    frame.size.height = 1;
    UIView *headerView = [[UIView alloc] initWithFrame:frame];
    [tblvw setTableHeaderView:headerView];
======================================================

How To Local Search And Paging Scrolling Content Ios/iphone

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

{
  
 [searchBarClient resignFirstResponder];
   
 

 if (!isSearching)
{
      
    CGFloat offcet=scrollView.contentOffset.y;
 
 
   
  if(offcet == 1)
  

     {
    
   
       [tblVwClientList setContentOffset:CGPointMake(0, 44) animated:YES];


     }
       

else if (scrollView.contentOffset.y >= (scrollView.contentSize.height - scrollView.frame.size.height))

{
         
  //else if (scrollView.contentOffset.y + scrollView.frame.size.height >= scrollView.contentSize.height - 70)

{
           
           
        
   if ([ApplicationData sharedInstance].isLodding)
    
    
  {
              
 [self callWebServiceGetClientPageWise];
 
        
 }
        
   else
        
   {
     

          // NSLog(@"page called");
             
  // [self callWebServicePageWise];
              
 //pageNumber=pageNumber+1;
  
 
       }
 
         
     
  }
   
    // [searchBarClient resignFirstResponder];



   }
   

}

- (void)searchLocalArrayList
{
  
 NSString *searchString = searchBar.text;


  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.clientName contains[cd] %@",searchString];


   NSMutableArray *arrType;
  
 arrType = [[NSMutableArray alloc] initWithArray:yourMaiinArray];

   [arrType filterUsingPredicate:predicate];
   
 
  searchResultArray = arrType;

}

Wednesday 17 February 2016

how to login Facebook Ios 9 iphone

AppDelegate.m file

    #import <FBSDKLoginKit/FBSDKLoginKit.h>
    #import <FBSDKCoreKit/FBSDKCoreKit.h>

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
  return [[FBSDKApplicationDelegate sharedInstance]
application:application   openURL:url
   sourceApplication:sourceApplication
                      annotation:annotation];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
  [FBSDKAppEvents activateApp];
}

- (BOOL)application:(UIApplication *)application
      didFinishLaunchingWithOptions:

(NSDictionary *)launchOptions {
  return [[FBSDKApplicationDelegate sharedInstance]
application:application didFinishLaunchingWithOptions:launchOptions];



 ==>Login ViewController.m


-(IBAction)facebookLogin:(id)sender
{
  FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];

   if ([FBSDKAccessToken currentAccessToken])
   {
     NSLog(@"Token is available : %@",

[[FBSDKAccessToken currentAccessToken]tokenString]);
        [self fetchUserInfo];
    }
    else
    {
 [login logInWithReadPermissions:@[@"email"] fromViewController:

 self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
         {
             if (error)
             {
                 NSLog(@"Login process error");
             }
             else if (result.isCancelled)
             {
                 NSLog(@"User cancelled login");
             }
             else
             {
                 NSLog(@"Login Success");

       if ([result.grantedPermissions containsObject:@"email"])
           {
          NSLog(@"result is:%@",result);
        [self fetchUserInfo];
          }
        else
           {
 [SVProgressHUD showErrorWithStatus:@"Facebook email permission error"];

           }
             }
         }];
    }
}

-(void)fetchUserInfo
{
    if ([FBSDKAccessToken currentAccessToken])
    {
        NSLog(@"Token is available : %@",

[[FBSDKAccessToken currentAccessToken]tokenString]);

        [[[FBSDKGraphRequest alloc] initWithGraphPath:

@"me" parameters:@{@"fields": @"id, name, email"}]
         startWithCompletionHandler:

^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
             if (!error)
             {
                 NSLog(@"results:%@",result);

                 NSString *email = [result objectForKey:@"email"];
                 NSString *userId = [result objectForKey:@"id"];

                 if (email.length >0 )
                 {
                     //Start you app Todo
                 }
                 else
                 {
                    NSLog(@“Facebook email is not verified");
                 }
             }
             else
             {
                 NSLog(@"Error %@",error);
            }
         }];
    }
}