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基础知识精讲 #### 一、Objective-C概述 Objective-C是一种通用、面向对象的编程语言,由苹果公司广泛应用于其操作系统Mac OS X和iOS的软件开发中。它结合了C语言的基础语法和Smalltalk的面向对象...
Objective-C对于拥有面向对象编程和C语言基础的开发者来说,学习起来相对容易,因此本书《Learn Objective-C》被推荐给那些想要快速掌握Objective-C编程的初学者。 书中首先强调了面向对象的基本概念和C语言知识...
Objective-C是一种主要在苹果的Mac OS X和iOS操作系统上使用的面向对象的编程语言,它继承了C语言的特性同时加入了Smalltalk风格的面向对象编程特性。自从2014年苹果公司发布了Swift编程语言之后,Objective-C的地位...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...