Skip to content

Instantly share code, notes, and snippets.

View NYiPhoneDeveloper's full-sized avatar

Nat Aguilar NYiPhoneDeveloper

View GitHub Profile
@NYiPhoneDeveloper
NYiPhoneDeveloper / gist:5120310
Created March 8, 2013 22:09
UITextField allowing only 1 decimal and no decimals at the beginning
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSCharacterSet *nonNumberSet = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789."] invertedSet];
// allow backspace
if (range.length > 0 && [string length] == 0)
{
return YES;
}
// Comment out to allow decimal at the beginning
// do not allow . at the beggining
// Multidimentional arrays
int n = 2, m = 4;
int matrix[n][m];
int i = 0;
for (unsigned x = 0; x < n; x++)
{
for (unsigned y = 0; y < m; y++)
{
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSMutableArray *collectionArray = [[NSMutableArray alloc] init];
NSArray *numArray = [[NSArray alloc] init];
NSArray *strArray = [[NSArray alloc] init];
#import <UIKit/UIKit.h>
#define kSelectedTabDefaultsKey @"Selected Tab"
enum {
kByName,
kByObject,
};
@interface ToDoListViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UITabBarDelegate, UIAlertViewDelegate, NSFetchedResultsControllerDelegate>
{
- (void)viewDidLoad
{
[segmentControl addTarget: self action: @selector(segmentChanged:) forControlEvents: UIControlEventValueChanged];
[super viewDidLoad];
}
-(IBAction) segmentChanged: (id) sender
{
NSInteger segmentChoice = [segmentControl selectedSegmentIndex];
#import "UsingViewsViewController.h"
@implementation UsingViewsViewController
@synthesize pageControl;
@synthesize image_1, image_2;
/*
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
MyViewController *viewController = [[MyViewController alloc] initWithNibName: @"MyViewController" bundle: [NSBundle mainBundle]];
self.myViewController = viewController;
[window addSubview: [myViewController view]];
[window makeKeyAndVisible];
NSArray *colorList = [NSArray arrayWithObject: [NSDictionary dictionaryWithObjectsAndKeys:
@"BrownColor", @"titleValue", [UIColor brownColor], @"colorValue", nil],
[NSDictionary dictionaryWithObjectsAndKeys: @"orangeColor", @"titleValue", [UIColor orangeColor], @"colorValue", nil],
[NSDictionary dictionaryWithObjectsAndKeys: @"purpleColor", @"titleValue", [UIColor purpleColor], @"colorValue", nil];
[NSDictionary dictionaryWithObjectsAndKeys: @"redColor", @"titleValue", [UIColor redColor], @"colorValue", nil], nil];
[colorList retain];
// Playing with some new code
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
// The delegates are something that we shall use in order to get more usefulness out of the
// Application -It is given, and free funcitonality.
@interface AttentionViewController : UIViewController <UIAlertViewDelegate, UIActionSheetDelegate>
{
IBOutlet UILabel *statusText;
}
#import "FlowerColorTableViewController.h"
#define sectionCount 2
#define redSection 0
#define blueSection 1
@implementation FlowerColorTableViewController
#pragma mark -