This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void swap (int a, int b){ | |
a = a+b; //9 = 4+5 | |
b = a-b; //4 = 9-5 | |
a = a-b; //5 = 9-4 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void swap(int a. int b ) { | |
a= a^b; | |
b= a^b; | |
a= a^b; // XOR operation | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{ | |
int length = [[self formatNumber:[textField text]] length]; | |
if (length == 10) { | |
// [self textFieldShouldEndEditing:textField]; | |
if(range.length == 0) { | |
return NO; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)locationManager:(CLLocationManager *)manager | |
didUpdateLocations:(NSArray *)locations{ | |
CLLocation *currentLocation = [locations lastObject]; | |
if (currentLocation != nil) { | |
NSLog(@" Longitude: %@",[NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude]); | |
NSLog(@"Latitude: %@",[NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude]); | |
} | |
[self.locationManager stopUpdatingLocation]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section | |
{ | |
UIView *view = [[UIView alloc ]initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 18)]; | |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, tableView.frame.size.width, 18)]; | |
[label setFont:[UIFont boldSystemFontOfSize:12]]; | |
NSString *string =@"Enter Email Address"; | |
/* Section header is in 0th index... */ | |
[label setText:string]; | |
view.backgroundColor = [UIColor clearColor]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <QuartzCore/QuartzCore.h> | |
UIImageView * roundedView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"wood.jpg"]]; | |
// Get the Layer of any view | |
CALayer * l = [roundedView layer]; | |
[l setMasksToBounds:YES]; | |
[l setCornerRadius:10.0]; | |
// You can even add a border | |
[l setBorderWidth:4.0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | |
[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForItem:indexPath.row inSection:indexPath.section]].accessoryType = UITableViewCellAccessoryCheckmark; | |
[self deSelectOtherCellsInTableView:tableView Except:indexPath]; | |
} | |
-(void)deSelectOtherCellsInTableView:(UITableView *)tableView Except:(NSIndexPath *)indexPath{ | |
for(UITableViewCell *cell in [tableView visibleCells]){ | |
NSIndexPath *index = [tableView indexPathForCell:cell]; | |
if(index.section == indexPath.section && index.row != indexPath.row){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; | |
} | |
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import SystemConfiguration | |
public let ReachabilityChangedNotification = "ReachabilityChangedNotification" | |
class HTSDReachabiltiy: NSObject { | |
typealias NetworkReachable = (HTSDReachabiltiy) -> () | |
typealias NetworkUnreachable = (HTSDReachabiltiy) -> () | |
enum NetworkStatus: CustomStringConvertible { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UICollectionView { | |
func registerCell(cellType:UICollectionViewCell.Type) { | |
self.registerNib(cellType.nib(), forCellWithReuseIdentifier: cellType.id()) | |
} | |
func registerSupplementaryView(classType:UICollectionReusableView.Type, kind:String) { | |
self.registerNib(classType.nib(), forSupplementaryViewOfKind: kind, withReuseIdentifier: classType.id()) |
OlderNewer