Friday, September 15, 2017

Simple URLRequest in objective c

-(void) getPlaces: (NSString *) googleType {

    NSString * newRadius = 100;
    
    NSString *url = [NSString stringWithFormat:@"urlHere?location=%f,%f&radius=%@&types=%@&sensor=true&key=%@", CurrentLat, CurrentLong, newRadius, googleType, kGOOGLE_API_KEY];
    
    //Formulate the string as a URL object.
    NSURL *googleRequestURL=[NSURL URLWithString:url];
    
    
    dispatch_queue_t mainQueue = dispatch_get_main_queue();
    
    dispatch_async(mainQueue, ^{
        
        NSData* data = [NSData dataWithContentsOfURL: googleRequestURL];
        [self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES];
        
    });
    
    
}

-(void)fetchedData:(NSData *)responseData {
    //parse out the json data
    [refreshController endRefreshing];
    HIDE_PROGRESS;
    
    if (responseData == nil) {
        return;
    }
    
    NSError* error;
    NSDictionary* json = [NSJSONSerialization
                          JSONObjectWithData:responseData
                          
                          options:kNilOptions
           
                          error:&error];
    
    NSArray* places ;
        
        if ([[json objectForKey:@"status"] isEqualToString:@"0"]) {
            
        }
        else
        {
          
                
        }

    resultArr = [[NSMutableArray alloc]initWithArray:places];
    
    [_resultTbl reloadData];

    NSLog(@"Google Data: %@", places);

}

Upload UIImage as base64 String

Upload UIImage as Base64 String (Upload UIImage as string) //Select Pic From Camera or Gallery       @objc func btnPro...