Try the search, it's linked to some great forums

Showing posts with label snippet. Show all posts
Showing posts with label snippet. Show all posts

Tuesday, January 19, 2016

Unity notes

Unity is the premier 2D/3D gaming platform out there.  I've just started going through a series of tutorials from Stone River Learning.  They're very nice.

Here's code for a 'constructor'.  A constructor is when a class or struct is created, its constructor is called. Constructors have the same name as the class or struct, and they usually initialize the data members of the new object. 
and here's a code snippet;
    public struct Question
    {
        public string questionText;
        public string[] answers;
        public int correctAnswer;

// This is the constructor that initializes the Question struct/object
        public Question(string questionText, string[] answers, int correctAnswer)
        {
            this.questionText = questionText;
            this.answers = answers;
            this.correctAnswer = correctAnswer;
        }

    }
        
    public Question testQuestion = new Question ("What is your favorite color?", new string[]{"blue","green","yellow"}, 0);


Enumeration snippet;
            foreach (GameObject p in TriviaPanels) {
                p.SetActive (false);


Here's another note;
 
 

Friday, November 13, 2015

NSUserDefaults - Persisting data & passing it around viewCOntrollers

This is a very simple way to pass parameters between various views.

1st in the appDelegate.m file add;
// NSUserDefault setup for passing info around the app the starting default values.
        [[NSUserDefaults standardUserDefaults] setInteger:0     forKey:@"list_filtered"];
        [[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"selected_spreadsheet"];
        [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"selected_map_type"];
        [[NSUserDefaults standardUserDefaults] setObject:@"ALL" forKey:@"selected_driver"];
        [[NSUserDefaults standardUserDefaults] setObject:@"initialString" forKey:@"selected_plist"];
        [[NSUserDefaults standardUserDefaults] setObject:@"initialDictionary" forKey:@"selected_member"];
        [[NSUserDefaults standardUserDefaults] setObject:@"selectedIndexPath" forKey:@"selected_indexPath"];
       
// sync the defaults to disk
        [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
        [[NSUserDefaults standardUserDefaults] synchronize];

Friday, July 17, 2015

Simple Database creation for Apps

This is my quick go to for creating a data file to use in an app.  There are other better, quicker and more complex, but this is quick & easy/peasey!
  • Create a CSV file in the speadsheet of your choice.  I use either Google's or OpenOffice.
  • Run the file thru my favorite converter - Plist Converter, by cc ccc.  It's also easy.  Couldn't find the url, but here's what it looks like;
 
  • Copy the resultant fileName.plist into your project.
  •  Write yourself some code to translae it into an NSArray or somethin'.



That's all she wrote.

Monday, December 29, 2014

Keyboard configuration

The following will hide a keyboard nicely;

// Hides a keyboard by use of an invisible button on view
// configure UIButton - Custom, no title & size over touch area
-(IBAction)hideButton:(UIButton *)sender
{
    NSLog(@"Hides the keyboard");
    [self.view endEditing:YES];
}

Here's another way that's less of a cludge; 
 It sets up a gesture for the view

1- Set the .h file to <UIGestureRecognizerDelegate>

2 - Add this to the viewDidLoad to set up the gestureRecognizer
// Tap to hide keyboard
    UITapGestureRecognizer *hideKeyboardTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideTap:)];
    [self.view addGestureRecognizer:hideKeyboardTap];

Probably the BEST way;
1 - Don't forget to set the class as a UITextFieldDelegate
2- Add to viewDidLoad for all textFields - self.textField.delegate = self;
3 - And finally the delegate method
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}



3 - Add this method
- (void)hideTap:(UIGestureRecognizer *)gestureRecognizer
{
    [self.view endEditing:YES];
    NSLog(@"Hides the keyboard");
}

Friday, June 6, 2014

CoreData, SQLite and terminal Shtuff

These are some simple commands that can be used in terminal to manipulate data & files

Unix commands:
ls       list files
cd      change directory (directories should have NO embedded spaces for this Unix cmd
md     make directory
cd ..   up a directory help duh?

link for command tool UNIX commands - http://www.cs.colostate.edu/helpdocs/vi.html

sqlite3 commands:
sqlite3 filename.db   Opens the filename database
.help                          guess what

Xcode commands: 
-com.apple.CoreData.SQLDebug 1   Add as a schema argument to allow debugging of SQLite code
            goto Product/Edit Schema/Run app/Arguments/Arguments passed on Launch

Monday, May 19, 2014

Rounded Rectangle Buttons in iOS 7 - Old school!

iOS 7 has moved away from realistic UI into this new world of flatness.   One element that doesn't work for me is the new UIButton which I guess is supposed to look like a link or something.  Ugh!
Here is a simple way to achieve the simple gray rounded rectangle of yester years.  Courtesy of tech tutorials and their great little YouTube tutorial



In the Identity Inspector add the 2 new Runtime attributes. 
Set background color & text in the Attributes Inspector.

Here's another good tutorial; http://ios-blog.co.uk/tutorials/user-defined-runtime-attributes/ 

Now for some geeky details;
These attributes (properties) are properties of CALayer