Skip to content

Instantly share code, notes, and snippets.

View SquaredTiki's full-sized avatar

Josh Garnham SquaredTiki

View GitHub Profile
- (IBAction)add:(id)sender {
UIButton *sampleButton = [[UIButton alloc] initWithFrame:CGRectMake(50.0f, 50.0f, 100.0f, 46.0f)];
UIImage *backgroundImage = [[UIImage imageNamed:@"redButton.png"] stretchableImageWithLeftCapWidth:11.0 topCapHeight:0.0];
[sampleButton setBackgroundImage:backgroundImage forState:UIControlStateNormal];
[self.view addSubview:sampleButton];
}
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
[self setBackgroundImage:[UIImage imageWithContentsOfFile: [[NSBundle mainBundle]
pathForResource:@"TransparentButtonFillN"
ofType:@"png"]]
forState:UIControlStateNormal];
}
return self;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchDown");
UITouch *touch = [touches anyObject];
UIView *aView = [self.view viewWithTag:1];
firstTouch = [touch locationInView:self.view];
if (CGRectContainsPoint(aView.frame, firstTouch)) {
butContains = YES;
NSLog(@"butContains = %d", butContains);
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchDown");
UITouch *touch = [touches anyObject];
firstTouch = [touch locationInView:self.view];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *array = [touches allObjects];
UITouch *specificTouch = [array objectAtIndex:0];
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchDown");
UITouch *touch = [touches anyObject];
firstTouch = [touch locationInView:self.view];
lastTouch = [touch locationInView:self.view];
[self.view setNeedsDisplay];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
- (void)outlineView:(NSOutlineView *)outlineView
willDisplayCell:(id)cell
forTableColumn:(NSTableColumn *)tableColumn
item:(id)item {
NSColor *color = [cell backgroundColor];
NSLog(@"Colorizing Method B");
if (clicked == YES) {
if (color == [NSColor lightGrayColor]) {
}else{
[cell setBackgroundColor:[NSColor lightGrayColor]];
NSNotificationCenter *nc;
nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self
name:NSManagedObjectContextObjectsDidChangeNotification
object:nil];
NSManagedObjectContext *moc = [self managedObjectContext];
[syncButton setTitle:@"Syncing..."];
NSString *dateText = (@"Last Sync : %d", [NSDate date]);
[syncDate setStringValue:dateText];
NSEntityDescription *entityDescription = [NSEntityDescription
- (void)awakeFromNib {
NSNotificationCenter *nc;
nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(syncKVO:)
name:NSManagedObjectContextObjectsDidChangeNotification
object:nil];
}
- (void)syncKVO:(NSNotification *)notification {
NSDictionary *userInfoDictionary = [notification userInfo];
NSSet *deletedObjects = [userInfoDictionary objectForKey:NSDeletedObjectsKey];
NSSet *changedObjects = [userInfoDictionary objectForKey:NSUpdatedObjectsKey];
if ([deletedObjects count]) {
//do something if it contains objects
} else {
if ([changedObjects count]) {
//do something if it contains objects
// Code in App Delegate.
- (void) awakeFromNib {
NSNotificationCenter *nc;
nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(syncKVO:)
name:NSManagedObjectContextObjectsDidChangeNotification
object:nil];