Learn Objective C(2)Learn Objective-C in Day 6 - 4 ~ 6
Car Example
Command-N (File ----> New File) ----> Cocoa Class under Mac OS X and select Objective-C
Name the class as SimpleCar and make it inherent from NSObject.
Interface and Implementation Coding
#import <Foundation/Foundation.h>
@interface SimpleCar : NSObject
@property (weak, nonatomic) NSString *make;
@property (weak, nonatomic) NSString *model;
@property (weak, nonatomic) NSNumber *vin;
-(void) setMake:(NSString*)newMake
andModel:(NSString*)newModel;
@end
That is the interface.
#import "SimpleCar.h"
@implementation SimpleCar
@synthesize make, model, vin;
-(void) setMake:(NSString *)newMake
andModel:(NSString *)newModel{
[selfsetMake: newMake];
[selfsetModel: newModel];
}
@end
Here is the implementation. @properties and @synthesize make it easy to do something like getter and setter.
References:
http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-4/
http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-5/
http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-6/
Objective C Book from Apple
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html
相关推荐
Objective-C to using it confidently in your own applications. This isnɅt a rush job – so donɅt expect to just skim through the basics and be away – weɅll be going through not just the bare ...
Learning Apache Spark 2 by Muhammad Asif Abbasi English | 6 Jun. 2017 | ASIN: B01M7RO7US | 356 Pages | AZW3 | 16.22 MB Key Features Exclusive guide that covers how to get up and running with fast ...
This language has shown a number of improvements in terms of functionality compared to the Objective-C programming language. iOS 8 has shown improved support for amazing features which were not ...
the first one covers the basic data structures that are built into most languages such as Objective-C, C#, Java, and Swift. It will cover detailed analysis of the common data structures such as ...
You can spend days learning Objective-C, but even if you did have the time commitment to spend learning code, you still might be in the same place as before: clueless! This book will help you learn ...
Rewriting Objective-C functions in Swift Efficiently managing layouts and view hierarchies with size classes Inspecting and fixing interface issues with the new View Debugger Displaying and ...
This book is for intermediate to advanced iOS/macOS developers who are already familiar with either Swift or Objective-C and want to take their debugging skills to the next level. Topics Covered in ...
Meant for a reader who knows object-oriented programming, has some experience with Objective-C/Swift programming languages and wants to further enhance his skills with functional programming ...
This book is for intermediate to advanced iOS/macOS developers who are already familiar with either Swift or Objective-C and want to take their debugging skills to the next level. Topics Covered in ...
These practice tests cover it all to help you discover what you already know, what you still need to learn, and what to expect on exam day. Get a preview of the types of questions you'll see on the ...
Being able to write apps with Swift's beautiful, readable, and straightforward syntax instead of having to write clunky Objective-C code suddenly enabled a lot of people to play around with iOS ...
Objective-C code suddenly enabled a lot of people to play around with iOS development. For me, Swift sparked a renewed interest in developing iOS applications, and the new passion has remained ever ...
Swift has a lot of functional programming features that can be easily used, but most Objective-C and Swift programmers are not familiar with these tools. This book aims at simplifying the functional...
Meant for a reader who knows object-oriented programming, has some experience with Objective-C/Swift programming languages and wants to further enhance his skills with functional programming ...
the Web, or a network •Maintain and optimize application performance <br/>Your kit includes: •NEW—60-day evaluation version of Microsoft Visual Studio® .NET 2003 Professional Edition ...
•NEW—60-day evaluation version of Microsoft Visual Studio® .NET 2003 Professional Edition on DVD •Comprehensive self-paced study guide that maps to the objectives of the final exams ...
The objective of this book is to teach building modern day business web applications using java and other related technologies. This book teaches everything in details and in simpler way about ...