Monday, 30 November 2015

How To Set Floating Pont in TableViewHeaderView Ios/Iphone

CGFloat dummyViewHeight = 40;
UIView *dummyView = [[UIView alloc]

initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width,

dummyViewHeight)];
self.tableView.tableHeaderView = dummyView;
self.tableView.contentInset = UIEdgeInsetsMake(-dummyViewHeight, 0, 0, 0);

Saturday, 28 November 2015

how to Use Url Image Reguler Expressation Ios/iphone

 
    NSString *searchedString = [[arr objectAtIndex: indexPath.row]
 objectForKey: @"description"];
   
    NSRange rangeOfString = NSMakeRange(0, [searchedString length]);
    //NSLog(@"searchedString: %@", searchedString);
   
    NSString *pattern = @"src=\"([^\"]+)\"";
    NSError* error = nil;
    NSTextCheckingResult* match;
    NSRegularExpression* regex = [NSRegularExpression
regularExpressionWithPattern:pattern options:0 error:&error];
    NSArray *matchs = [regex matchesInString:searchedString
options:0 range:rangeOfString];
    for (match in matchs) {
        NSLog(@"url: %@", [searchedString substringWithRange:
[match rangeAtIndex:1]]);
      
    }

Friday, 27 November 2015

Work Selected Row By default and Check Mark In UITableView Ios/Iphone

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:0];
[self.tableView selectRowAtIndexPath:indexPath
                            animated:YES
                      scrollPosition:UITableViewScrollPositionNone];
[self tableView:self.tableView didSelectRowAtIndexPath:indexPath];





 ==> Selected Checkmark row



- (UITableViewCell *)tableView:(UITableView *)tableView

cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:

 CellIdentifier];

    if(cell == nil )
    {
        cell =[[[UITableViewCell alloc] initWithStyle:

 UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }
    if ([indexPath compare:self.lastIndexPath] == NSOrderedSame)
    {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }
    else
    {
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    return cell;
}

// UITableView Delegate Method
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:

(NSIndexPath *)indexPath
{
    self.lastIndexPath = indexPath;

    [tableView reloadData];
}

Thursday, 26 November 2015

How To Hide Navigation Bar Button ios Iphone

UIBarButtonItem *oldButton = self.navigationItem.rightBarButtonItem;
[oldButton retain];
self.navigationItem.rightBarButtonItem = nil;

//... later
self.navigationItem.rightBarButtonItem = oldButton;

Wednesday, 25 November 2015

How To Udr NSLocal Country name Ios/iphone

NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];

NSLocale *usLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]

 autorelease];

NSString *country = [usLocale displayNameForKey: NSLocaleCountryCode value:

 countryCode];

Tuesday, 24 November 2015

Work With NSNotification Center Ios/Iphone

=> Here User Dealloct Whiitch Used Notification:
- (void) dealloc
{
   
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}

- (id) init
{
    self = [super init];
    if (!self) return nil;

==> add observe Notification default center:-   

    [[NSNotificationCenter defaultCenter] addObserver:self
        selector:@selector(receiveTestNotification:)
        name:@"TestNotification"
        object:nil];

    return self;
}

=> have Received Notification:-



 - (void) receiveTestNotification:(NSNotification *) notification
{
    // [notification name] should always be @"TestNotification"
    // unless you use this method for observation of other notifications
    // as well.

    if ([[notification name] isEqualToString:@"TestNotification"])
        NSLog (@"Successfully received the test notification!");
}

@end



- (void) someMethod
{

    // All instances of TestClass will be notified
    [[NSNotificationCenter defaultCenter]
        postNotificationName:@"TestNotification"
        object:self];

}
=================================================================

NSDictionary *userInfo = [NSDictionary dictionaryWithObject:myObject

forKey:@"someKey"];
    [[NSNotificationCenter defaultCenter] postNotificationName:

 @"TestNotification" object:nil userInfo:userInfo]; 



- (void) receiveTestNotification:(NSNotification *) notification

    NSDictionary *userInfo = notification.userInfo;
    MyObject *myObject = [userInfo objectForKey:@"someKey"];
}

Saturday, 21 November 2015

How to Use Perfom Selector Ios/Iphone

dispatch_async(dispatch_get_main_queue(), ^{
    [self doSomething:1 b:2 c:3 d:4 e:5];
});



[ invocationObject performSelectorOnMainThread: @selector( invoke )

   withObject: nil, waitUntilDone: NO ];



- (void)threadMain:(id)data {
    NSAutoreleasePool *pool = [NSAutoreleasePool new];

    NSRunLoop *runloop = [NSRunLoop currentRunLoop];
    [runloop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode];

    while (isAlive) { // '
        [runloop runMode:NSDefaultRunLoopMode beforeDate:

[NSDate distantFuture]];
    }

    [pool release];
}