xcode etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
xcode etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

19 Mayıs 2015 Salı

Create a new Xcode Project in Swift Language

1. Launch Xcode



You can access Xcode from /Developer/Applications. When Xcode is launched, you see the Welcome screen. In the right column, most recent projects which you open are listed.



If you want to use Xcode without the Welcome screen , deselect the "Show This Window When Xcode Launches" check box.






2. Create a new Xcode project 


There are two ways to create a new project

a. Select  a new Xcode project

b. Select File->New-> Project
  

3.  Select an application type



There are a few templates in the New Project window such as Master-Detail Application, Page Based application, game etc.  According to your need , you can choice one of them.



4. Enter a project name and select language and device type.


   In the this window, project options are listed. You can choose iPhone, iPad or universal as device type and Swift or Objective-C as language. 




5. Choose Project location in your computer 



10 Şubat 2015 Salı

Swift Basics - Array and Dictionary


Simple Values

let -> make a constant
var -> make a variable 

In order to assign a value, we may not write type explicitly

Example:

    let constantValue = 20
        let constantValue2 : Int = 20

 Error:  Cannot assign to 'let' value 'constantValue'
constantValue = 30.5
 Error:  Cannot assign to 'let' value 'constantValue2’
        constantValue2 = 30

Change let to var
  var Value = 20
        var Value2 : Int = 20
      
 Error:  Type 'Int' does not conform to protocol 'FloatLiteralConvertible'
        Value = 30.5
  It’s OK
        Value2 = 30


Convert to “Int” type to “String” type

let stringValue = "The height of frame is "
        let height = 100
        let ​heightLabel​ = stringValue + String(height)
        
        
        println(​heightLabel​)

Convert to any type to String type basically.


  let height = 100
        let stringValue = "The height of frame is  \(height)"
        let ​heightLabel​ = stringValue
        
        
        println(​heightLabel​)


Change an item of array

        var arrayList = ["cat","dog","bird"]
        arrayList[1] = "penguen"
        
        for var i=0; i<arrayList.count; i++
        {println(arrayList[i])
        }

Add an item of array by using append method

        arrayList.append("bear")
 

Add an array of one or more compatible items
        arrayList += ["cow","butterfly"]

To insert an item into the array at a specified index:
        arrayList.insert("bee", atIndex: 4)

To remove an item from array
  arrayList.removeAtIndex(5)









24 Ocak 2015 Cumartesi

Basic AutoLayout Example in iOS - 1

Let's make a basic autolayout example.

Firstly add a blue view the upper left corner.

Add the constraints for the blue view

height = 100
width = 100


Update Frames for blue view






Seconly, add a purple view the center

Add the constraints for the purple view

height = 200
width = 200


In order to show a view on the center, we must add alignment constraints:
1. Horizontal center in Container
2. Vertical center in Container


Update Frames for purple view


Finally add a orange view the upper left corner.

Add the constraints for the orange view

height = 100
width = 100

Update Frames for orange view

Let's control storyboard preview for iPhone sizes.




Result for iPhone 6








You can download from  https://github.com/ozlemakalin/BasicAutoLayoutExample