Skip to content

Instantly share code, notes, and snippets.

View romyilano's full-sized avatar
😎
improving

Romy romyilano

😎
improving
View GitHub Profile
@romyilano
romyilano / ViewController.m
Created March 2, 2013 06:17
Add a custom gesture recognizer to a view from a raywenderlich tutorial
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
for (UIView *view in self.view.subviews)
{
// this is how you programmatically add a gustom gesture recognizer
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
recognizer.delegate=self;
CGRect passwordTextFieldFrame = CGRectMake(20.0f, 100.0f, 280.0f, 31.0f);
UITextField *passwordTextField = [[UITextField alloc] initWithFrame:passwordTextFieldFrame];
passwordTextField.placeholder = @"Password";
passwordTextField.backgroundColor = [UIColor whiteColor];
passwordTextField.textColor = [UIColor blackColor];
passwordTextField.font = [UIFont systemFontOfSize:14.0f];
passwordTextField.borderStyle = UITextBorderStyleRoundedRect;
passwordTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
passwordTextField.returnKeyType = UIReturnKeyDone;
passwordTextField.textAlignment = UITextAlignmentLeft;
@romyilano
romyilano / memorymanagement.m
Last active December 14, 2015 18:49
Memory Management Notes from Erica Sadun She kicks ass!!! =D
// Manual Reference counting (MRR) - just like Maximum Rock'n'Roll!
/*
With MRR you have to ensure that every object you allocate
Moves from the start to the finish of its life cycle without being prematurely
released and to guarantee that it does get finally released when it is time to do so
Complicating matters is objective-C's MRR autorelease pool.
If some objects are autoreleased and others must be released manaually how do you best control your objects?
@romyilano
romyilano / someCoolViewController.m
Created March 20, 2013 20:16
Matt Neuberg - how to make text adjust in a UILabel - Programming iOS 5
// thank you matt neuberg!!!
-(CGRect)textRectForBounds:(CGRect)bounds
limitedToNumberOfLines:(NSInteger)numberOfLines {
CGSize sz = [self.text sizeWithFont:self.font
constrainedToSize:CGSizeMake(self.bounds.size.width, 10000)
lineBreakMode:self.lineBreakMode];
return (CGRect) {bounds.origin, CGSizeMake(self.bounds.size.width, sz.height)];
}
@romyilano
romyilano / ViewController.m
Last active December 16, 2015 03:19
Women Who Code iOS Study group Michele Titolo showed us how to check only for numbers in a UITextFIeld thanks for sponsoring us, SocialChorus!
#pragma mark -
#pragma mark - UITextFieldDelegate
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
// let's check if the string is range is a number
NSRange characterRange = [string rangeOfCharacterFromSet:[NSCharacterSet letterCharacterSet]];
// if we've detected a character in our string, we're not going to insert that letter character in our text field
if(characterRange.location != NSNotFound) {
return NO;
//
// MasterViewController.m
// CoffeeShop
//
//
// Copyright (c) 2013 uihelpers. All rights reserved.
//
#import "MasterViewController.h"
#import <RestKit/RestKit.h>
#import "Venue.h"
@romyilano
romyilano / test.m
Created April 15, 2013 06:06
Check if gyroscope is available... nice macro for detecting iPhone os versions
- (BOOL) isGyroscopeAvailable
{
#ifdef __IPHONE_4_0
CMMotionManager *motionManager = [[CMMotionManager alloc] init];
BOOL gyroscopeAvailable = motionManager.gyroAvailable;
[motionManager release];
return gyroscopeAvailable;
#else
return NO;
#endif
@romyilano
romyilano / augmented.m
Created April 15, 2013 06:12
Check if various hardware components are available. source: professional iOS augmented reality dev.
//
// FirstViewController.m
// iOS_AR_Ch2_HardwareComparison
//
// Created by Kyle Roche on 6/13/11.
// Copyright 2011 Isidorey. All rights reserved.
//
#import "FirstViewController.h"
@romyilano
romyilano / objectiveC-StructReview.m
Last active December 16, 2015 06:09
review of Structs Creating iOS 5 Apps, Develope and design
/*
Structs are the most flexible C data type
can combine different types of data, access that data using named fields
makes heavy use of C Structures -- many Core Frameworks in ObjC are written in pure C
*/
struct CGPoint {
CGFloat x;
CGFloat y;
};
@romyilano
romyilano / objC-enumerationreview.m
Created April 15, 2013 16:51
From Creating iOS5 apps Develop & Design - thanks! review of enumeations
// Enumerations provide a concise, elegant method for defining a discrete set of values
typedef enum {
SUNDAY,
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY