Dab tsi yog chav kawm abstract hauv Swift?
Dab tsi yog chav kawm abstract hauv Swift?

Video: Dab tsi yog chav kawm abstract hauv Swift?

Video: Dab tsi yog chav kawm abstract hauv Swift?
Video: TUDev's Tech Talk with Professor Bora Ozkan - Fintech and the Future of Finance 2024, Kaum ib hlis
Anonim

Tsis muaj Cov chav kawm abstract hauv Swift (ib yam li Objective-C). Koj qhov thawj koom ruam zoo tshaj plaws yog yuav siv Tus Txheej Txheem, uas zoo li Java Interface. Nrog Swift 2.0, tom qab ntawd koj tuaj yeem ntxiv cov kev coj ua thiab suav cov cuab yeej siv tau siv cov txheej txheem txuas ntxiv.

Kuj paub, dab tsi yog chav kawm paub daws teeb meem iOS?

Ib qho ntawm cov lus nug uas nquag nug txog iOS no developer xam phaj yog - qhov sib txawv ntawm abstract classed thiab interface. Abstract chav kawm yog a chav kawm , uas tsuas yog siv los tsim cov subclasses zais thiab nws yuav tsum tsis txhob muaj cov txheej txheem init (yog tias kuv nkag siab qhov tseeb).

Ib sab saum toj no, chav kawm paub daws teeb meem puas tuaj yeem muaj txoj hauv kev ib txwm muaj? A chav kawm uas tau tshaj tawm tias siv abstract ” lo lus tseem ceeb yog hu ua chav kawm abstract . Nws tuaj yeem muaj kev paub daws teeb meem ( txoj kev tsis muaj lub cev) nrog rau pob zeb txoj kev (ib txwm txoj kev nrog lub cev). Ib abstract chav kawm tau tsis tau instantiated, uas txhais tau hais tias koj tsis raug tso cai los tsim ib yam khoom ntawm nws.

Tom qab ntawd, lo lus nug yog, dab tsi yog encapsulation hauv Swift?

Encapsulation yog ib qho tseem ceeb tshaj plaws ntawm cov qauv tsim qauv: Nws hides lub xeev sab hauv thiab kev ua haujlwm ntawm cov khoom. Koj tuaj yeem ua tiav qhov no los ntawm kev siv cov kev tswj hwm kev nkag mus ntawm Swift.

Koj tuaj yeem txhais tau li cas hauv chav kawm hauv Swift?

Ib qho chav kawm uas tsis tau txais los ntawm lwm tus chav kawm yog lub npe hu ua a chav kawm hauv paus . Swift chav kawm tsis tau txais los ntawm universal chav kawm hauv paus . Cov chav kawm koj txhais yam tsis tau qhia ib tug superclass cia li ua cov chav kawm hauv paus rau koj los txhim kho.

Pom zoo: