iOS Dev – Lecture #3: Foundation Classes

The third lecture starts with a review of the last lectures followed by an introduction to data structures in Objective-C. Numbers are represented as int, float, double, NSNumber, booleans as BOOL, Strings as NSString and NSMutableString, dates as NSDate, and binary data as NSData. Further primitives are NSIndex and NSValue.
As collections there are arrays represented as NSArray and NSMutableArray, sets as NSSet and NSMutableSet, and dictionaries as NSDictionary and NSMutableDictionary.
In addition there are blocks for executable code.

Foundation classes are by default immutable which has the advantage of having no unwanted side-effects when passing objects to methods. To be changeable after initialization they have to be defined as Mutable.
Continue reading “iOS Dev – Lecture #3: Foundation Classes”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Assignment #1 – Extra Task #2

Visualize the currently active operation by letting the button be pushed until the second operand is entered.

A button can be displayed as pushed by “highlighting”. However, when the resultButtonPressed: method fires, the button is already highlighted and will be dehighlighted shortly after. Thus it is necessary to “wait a little bit” actually till the “normal button functionality” has finished before highlighting the button. This can be achieved by adding an operation on the main queue.
To remove the highlighting, add a property to hold the currently pressed button.

@property (nonatomic, strong) UIButton *currentButton;

- (IBAction)operationButtonPressed:(UIButton *)sender {
	...
	else
	{
		...
		self.currentButton.highlighted = NO;
	}
	...
	[[NSOperationQueue mainQueue] addOperationWithBlock:^{
		sender.highlighted = YES;
		self.currentButton = sender;
	}];
}

- (IBAction)resultButtonPressed:(id)sender {
	...
	self.currentButton.highlighted = NO;
}

- (IBAction)clearDisplay:(id)sender {
	...
	self.currentButton.highlighted = NO;
}
FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Assignment #1 – Extra Task #1

Adapt the number of shown decimals to the actual result that is to be displayed.

Actually NSNumber does that all. Thus we just have to create an NSNumber from the number before we display it. At the same time we change all floats to doubles to reduce the problem of the “float feature” described before:

- (IBAction)operationButtonPressed:(UIButton *)sender {
    ...
    self.numberTextField.text = [NSString stringWithFormat:@"%@", 
         [NSNumber numberWithDouble:firstOperand]];        
    ...
}

- (IBAction)resultButtonPressed:(id)sender {
    ...
    self.numberTextField.text = [NSString stringWithFormat:@"%@", [NSNumber numberWithDouble:result]];
    ...
}
FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Assignment #1

We provide you with a template for a calculator that already adds numbers (at least 1 and 2).
Take a close look at the implementation of this template and write the necessary code to have a fully working calculator.

Let’s have a look at the number buttons:

iOS Dev - Assignment #1 - Number Actions
iOS Dev – Assignment #1 – Number Actions

Continue reading “iOS Dev – Assignment #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Lectures #1 & #2: Introduction & Objective-C

The first lecture provides an introduction to mobile development on the iOS device family. As assignment it is required to read the iOS Human Interface Guidelines.

The second lecture explains the programming language Objective-C and Memory Management.

The lecture videos and its slices are available on iTunes.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Xcode 4.5.2

Xcode has been updated to version 4.5.2 for Lion and Mountain Lion and is now available at the Mac App Store:

  • Support for iPad mini and iPad with Retina display (4th generation).
  • Additional bug fixes and stability improvements.
  • & further bug fixes and stability improvements.

A more detailed description can be found at “What’s new in Xcode” or in the Xcode Release Notes.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail