網頁

2012年2月9日 星期四

Xcode 4.2

Xcode 4.2: How to Create MainWindow .xib File!


Xcode for beginners 02 - Hello World



IOS5 Table View Controller With Cell Views, Navigation Controller, Storyboard There are two types of accessor methods, and each method must conform to a naming convention.
A “getter” accessor method, which returns the value of a property, has the same name as the property.
A "setter” accessor method, which sets a new value for a property,



---
And remember that synthesize creates the setter and the getter.


Now when is the stter gonna be used for this property and when is the getter?


The setter is gonna br used by iOS to set this pointer when the storyboard gets loaded up and this thing appers on screen.
It's gonna call the setter to create that connection to label(Objects).


The getter, we're gonna call in our code anytime we want to talk to that label. We'll call the getter, get the pointer to it and send it messages.


---
If you don't synchronize, your data will not be getting saved, so definitely synchronize. Synchronize is not free but it's pretty cheap.
---
Can classes have properties or instance variables? 
No , they cannot. That's the whole thing of an instance. An instance is a storage area for instance variables and properties. the properties and instance variables as well. 


So a class, since it's not instance, it has nowhere to store that stuff. So it cannot have any. 
--



So on the left, also notice that it puts a little M in the navigator by any file that's been modified.
And if you add a file, like we added when we added calculator brain it would put an A.


----
How does a gesture recognizer work? 
Basically, a gesture recognize is an object that you attach to a view and it ewatches the touch events that happen in that view.


----
The only other thing we do is wire up our ourlet. Our controller has an outlet that hooks up to our FaceView.





We could do that by, for example, bringing up the assistant editor right here(MainStoryBoard) , going over here(.h). And using control drag to hook this up, right?
Another quick way to do it, whcih is that this little icon down here, that represents  your controller. So I can actually control drag from here(MainStoryBoard), okey, if I want, up to my FaceView. See how it highlights? And when I let go, you can see it's going to let me pick,  and I told you all controllers have this outlet called view,  which is the top level view, but I want to hook this one up to FaceView.
----



What were the magic keys I used. Very good.
So I use -- I selected the text that I wanted to replace, okay?
Like pop operand, and then I used command E, which I believe is a standard key binding.
I try not to change my key bindings on this computer, so that I'm not doing magic.
But it's basically enter text into the find button, whatever  that -- I think the command E is what it is.


And so that when you do command E, then you can search using command G, whcih means find next, And then to replace it, I was just doing copy, paste.


I copied the right things, and then I did command E, and command G. Paste, paste, paste, okay? command G. paste.

--

to say another thing too, which is the programing credo I live by is that the line of code that is the most elegant has by far the least bugs, is the easiest to wirte, is the easiest for someone else reading your code to understand, that line of code is the code you never write.


Fewer lines of code is better, that's what progrming elegance about.
---
Just remember that for every @property directive in the interface (.h) file, you should have a corresponding  @synthesize directive in the implementaion (.m) file





Note: A protocol is basically just a list of methods. If a class conforms to (or adopts) a protocol, it guarantees that it implements the required methods of a protocol. (Protocols can also include optional methods.) A delegate protocol specifies all the messages an object might send to its delegate.


Xcode 4.2 / Product / Profile

To ensure that you deliver the best user experience for your software, launch the Instruments application from Xcode to analyze 


image: ../Art/instruments_showcase.png




Type
Description and literal
id
The dynamic object type. The negative literal for both dynamically and statically typed objects is nil.
Class
The dynamic class type. Its negative literal is Nil.
SEL
The data type (typedef) of a selector; this data type represents a method signature at runtime. Its negative literal isNULL.
BOOL
A Boolean type. The literal values are YES and NO.

image: ../Art/collections.png



















A typical app bundle
File
Example
Description
App executable
MyApp
The executable file contains your app’s compiled code. The name of your app’s executable file is the same as your app name minus the .app extension.
This file is required.
The information property list file
Info.plist
The Info.plist file contains configuration data for the app. The system uses this data to determine how to interact with the app.
This file is required and must be called Info.plist. .
App icons
Icon.png
Icon@2x.png
Icon-Small.png
Icon-Small@2x.png
Your app icon is used to represent your app on the device’s Home screen. Other icons are used by the system in appropriate places. Icons with @2x in their filename are intended for devices with Retina displays.
An app icon is required.
Launch images
Default.png
Default-Portrait.png
Default-Landscape.png
The system uses this file as a temporary background while your app is launching. It is removed as soon as your app is ready to display its user interface.
At least one launch image is required.
Storyboard files (or nib files)
MainBoard.storyboard
Storyboards contain the views and view controllers that the app presents on screen. Views in a storyboard are organized according to the view controller that presents them. Storyboards also identify the transitions (called segues) that take the user from one set of views to another.
The name of the main storyboard file is set by Xcode when you create your project. You can change the name by assigning a different value to theNSMainStoryboardFile key in the Info.plist file. Apps that use nib files instead of storyboards can replace the NSMainStoryboardFile key with theNSMainNibFile key and use that key to specify their main nib file.
The use of storyboards is optional but recommended.
Ad hoc distribution icon
iTunesArtwork
If you are distributing your app ad hoc, include a 512 x 512 pixel version of your app icon. This icon is normally provided by the App Store from the materials you submit to iTunes Connect. However, because apps distributed ad hoc do not go through the App Store, your icon must be present in your app bundle instead. iTunes uses this icon to represent your app. (The file you specify should be the same one you would have submitted to the App Store, if you were distributing your app that way.)
The filename of this icon must be iTunesArtwork and must not include a filename extension. This file is required for ad hoc distribution but is optional otherwise.
Settings bundle
Settings.bundle
If you want to expose custom app preferences through the Settings app, you must include a settings bundle. This bundle contains the property list data and other resource files that define your app preferences. The Settings app uses the information in this bundle to assemble the interface elements required by your app.
This bundle is optional.
Nonlocalized resource files
sun.png
mydata.plist
Nonlocalized resources include things like images, sound files, movies, and custom data files that your app uses. All of these files should be placed at the top level of your app bundle.
Subdirectories for localized resources
en.lproj
fr.lproj
es.lproj
Localized resources must be placed in language-specific project directories, the names for which consist of an ISO 639-1 language abbreviation plus the .lprojsuffix. (For example, the en.lprojfr.lproj, and es.lproj directories contain resources localized for English, French, and Spanish.)
An iOS app should be internationalized and have a language.lproj directory for each language it supports. In addition to providing localized versions of your app’s custom resources, you can also localize your app icon, launch images, and Settings icon by placing files with the same name in your language-specific project directories.


ios5模拟器中的缩放手势模拟支持xcode



IBOutlet xib與storyboard      .h .m互通有無的溝通橋梁


呼叫method 一律以 [開頭,以]; 結束

ex [super viewDidLoad]; super 父母呼叫 slef 自己呼叫






-(void) setmyName:(char*)name andAge:(int)age
{


}


呼叫加了參數的method 
[self setMyName:"Peter" andAge:10];


@"" NSString類別的字串



想列印物件時,就得使用 %@

Objective-C 的世界裡,真正被呼叫的method是在APP執行時才動態決定的,到時變數指向哪個物件,即執行那物件的method


取得member值的method稱為getter
設定member值的method稱為setter


nil呼叫任何method都不會出事,因為它什麼事都不做


記得將經由alloc增加的retainCount扣除,否則將造成不死的member物件,塞滿記憶體空間



我們在宣告物件的@property時一般會傳入retain而不是assign 
因為我們將使用物件,為了防止他突然掛點,幫它增加retainCount比較保險


@property(nonatomic,retain) NSString *name;

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。