Extension Kullanımı ve kodlaması

in #utopian-io7 years ago (edited)

Selamlar , Bu dersimizde Extension tanımını ve kodlama şekillerinden bahsettim . Biraz uzun ders oldu , Umarım karışık olmamıştır . Dersleri kendim beğenmediğim sürece atmıyorum . 2 defa çektim sonunda beğendim . İyi seyirler , iyi dersler .

Greetings, In this lesson I talked about the definition of extensions and the coding styles. It was a long lesson, I hope it was not complicated. I do not throw lessons unless I like myself. I liked it 2 times at the end. Good looking, good lessons.


Projemizin Kodları
(Project Code)




import UIKit

**//Extension ile herhangi birşeye yeni bir özellik katılır**

var x = "Deneme" //String bir değişken

x.characters.count **//Swift 3 ile**

x.count **// Swift 4
**
extension String{

    var say:Int{

        return self.characters.count

    }

}

x.say

var y = "Türkçe Swift Programlama"

y.say

var a = 3.0 **//Afrika ülkelerinden birinin para birimi**

var b = 685.0 **// Ülkemizin para birimi**

var c = a/b

**//Virgülden sonra 2 basamak için : Sayı 100 ile çarpılır. 10 un 2. kuvveti**

**//Virgülden sonra 3 basamak için : Sayı 1000 ile çarpılır. 10 un 3. kuvveti**

**//Virgülden sonra 4 basamak için : Sayı 10000 ile çarpılır. 10 un 4. kuvveti**

(c*1000)

var d = (c*1000).rounded() //sayıyı yuvarlar

d/1000

extension Double{

    

    func sayiyiYuvarla(basamak:Int)->Double{

        let carpan = pow(10.0, Double(basamak))

        return (self*carpan).rounded()/carpan

    }

}

var e = 0.023456

e.sayiyiYuvarla(basamak: 4)

extension Int{

    mutating func kareAl(){

       self = self*self

    }

    

    func kareAlmak()->Int{

        return self*self

    }

    

    func cift()->String{

        

        if self % 2 == 0{

            return "Sayı Çifttir"

        } else{

            return "Sayı Tektir"

        }

    }

}

var k = 4

k.kareAl()

6.kareAlmak()

57.cift()

80.cift()






  • Video ya ingilizce çeviri yapana " 1 SBD " Ödül verilecektir

  • The person who makes video or english translation will be awarded "1 SBD".


Videoma ingilizce çeviri yapabilirsiniz
English subtitles can be added to the video.

Kodlara github adresimden'de ulaşabilirsiniz
You can access the code file from my "Githup" account


Önceki derslerimiz / Previous lessons.**




Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @kerimcaglar I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.15
TRX 0.12
JST 0.026
BTC 56855.76
ETH 2540.09
USDT 1.00
SBD 2.24