Hello World

This is the code of a simple Hello World application. As you can see I uploaded the .m and .h file and there are a lot of comments on each method.

If you need any further help for your application you should definitely check out Apple’s own developer section

Objective-C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// HelloWorldViewController.m
// HelloWorld
//
// Created by Joris Dubois on 19/02/12.
// Copyright (c) 2012 Xios Hogeschool Limburg. All rights reserved.
//
#import "HelloWorldViewController.h"
@interface HelloWorldViewController ()
@end
@implementation HelloWorldViewController
@synthesize nameField;
@synthesize lblLabel;
@synthesize userName = _userName;
//Autogenerated code.
//Triggered when the view is loaded.
- (void)viewDidLoad
{
[super viewDidLoad];
}
//Autogenerated code.
//Triggered when the view is unloaded.
- (void)viewDidUnload
{
[self setNameField:nil];
[self setLblLabel:nil];
[super viewDidUnload];
}
//Autogenerated code.
//Something about the rotation. Not important!
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
//Self written.
//Method that we want to trigger when we need to dismiss the keyboard.
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
//Checking if the object that triggered the method is 'nameField'.
if (theTextField == self.nameField) {
//Code to dismiss the keyboard by sending a resignFirstResponder.
[theTextField resignFirstResponder];
}
//return a boolean.
return YES;
}
//Self Written.
//Triggered when the clickButton is pressed.
- (IBAction)clickButton:(id)sender {
//The variable 'userName' has been refered to the 'nameField' text.
self.userName = self.nameField.text;
//Making a NSString named nameString and refer it to the variable 'userName'.
NSString *nameString = self.userName;
//If statement to check if the users input was "".
if([nameString length] == 0){
//Set nameString to "World".
nameString = @"World";
}
//Making a new NSString.
//initWithFormat is a method to create a new line of text by filling in a spot '%@'.
//This line of code produces the NSString: "Hello, NAME".
NSString *result = [[NSString alloc] initWithFormat:@"Hello, %@!",nameString];
//Set the text of 'lblLabel' to the result label.
self.lblLabel.text = result;
}
@end
Objective-C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//
// HelloWorldViewController.h
// HelloWorld
//
// Created by Joris Dubois on 19/02/12.
// Copyright (c) 2012 Xios Hogeschool Limburg. All rights reserved.
//
#import
//The HelloWorldViewController has implemented the .
//Why it needs to be implemented is going to be explained later.
@interface HelloWorldViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *nameField;
@property (weak, nonatomic) IBOutlet UILabel *lblLabel;
@property (copy,nonatomic) NSString *userName;
- (IBAction)clickButton:(id)sender;
@end

 

Sena ULTRASLIM

I used this leather pouch for over a year and must say this product is a great option if you don’t want to lose the looks of an original iPhone 4/4S
The appearance of this pouch is beautiful and they are available in different colors.
In the first couple of days its a little stiff to get the phone out of the pouch, but after a week or two
it becomes easier for sure.
There are little holes at the bottom of the product so the speakers are loud enough to hear when your phone is ringing or when someone sends you a message.
The only thing i dislike about the Sena pouch is that the stitches make small scratches on your iPhone’s glass.
These scratches are only visible if there are fingerprints on the screen.
This problem occurred after 3-4 months of use.
To end i posted some pictures of the scratches and the pouch itself.
My personal pro/con summary:
Positive:
 - looks
 - quality leather
 - variety of colors
 - sound holes
Negative:
 - scratches because of the stitches

The basic design patterns: Delegation pattern

The delegation pattern is a design pattern in object-oriented programming where an object, instead of performing one of its stated tasks, delegates that task to an associated helper object.

I will try to explain this as easy as possible. Lets say we want an object “dog” and an object “cat” for a game like Nintendogs.
The dog and cat can do different things. For example the dog can “bark” and the cat can “miauw”. But we can’t switch these items because a dog can’t “miauw”.
And thats why we make different objects for the cat and the dog.

If we look at the things that both the dog and the cat have in common we see that we can make an other object “animal” because both of them can “walk” and “drink”

If we look at ‘code’ it would look something like this:

dog = animal
cat = animal
dog.walk
cat.walk
dog.drink
dog.miauw (compilation error!)
cat.drink
dog.bark
cat.miauw

Now we can see that we didn’t duplicate the code of “drink” and “walk” in both the dog and cat objects.

The basic design patterns: Model-View-Controller

This pattern governs the overall structure of your application.

Okay, this is the first design pattern. As the title describes we got three kind of layers. First of all the View, second the model and as last the controller.

Lets start with the view.
The view is the user interface that you see when you are using an application. For example the buttons on the screen or a label.

The model is code that describes an object. For example a contact in an address book. This contact contains a first name, last name, address, phone number, etc.

The controller is the code that takes care off the communication between the view and the model.

Explanation of the image:
The view sends an action to the controller. The controller checks his sources and updates the model. Then the model notify’s the controller that everything is fine, and the object has been modified. As last the controller updates the user interface so the user also confirms everything has been updated correctly.