Ana sayfa Genel Swift 4, Faydalı String Metodları Bölüm 1

Swift 4, Faydalı String Metodları Bölüm 1

694
53
PAYLAŞ

Merhabalar,

Bu dersimizde swift dilinde kullanabileceğimiz faydalı methodlardan bahsedeceğiz.

  1. Bir String’in ilk harfini büyütme
  2. Bir Stringde ki kelimeleri büyük harfe çevirme
  3. Stringleri bağlayarak(concatenate) tek bir String oluşturma yöntemleri

Stringlerin ilk harfini büyütmeyle başlayalım:

Verilen bir stringde yalnızca ilk harfi büyütmek istiyorsak, aşağıdaki Extension ı projemize ekleyerek string değerlerimizde kullanabiliriz.

Yukarıdaki kod bloğunda ilk olarak Stringimizin birinci harfini belirliyor ve .capitalized metoduyla bunu büyük harfe çeviriyoruz. Ardından bu fonksiyon asıl değerimizi değiştireceği için mutating func olarak fonksiyonumuzu tekrar yazıp üstteki metodumuzu tekrar çağırıp self’e eşitliyoruz.

2 – Bir stringdeki tüm kelimelerin baş harfini büyütme:

capitalized metodunu kullanarak bir stringdeki tüm kelimeleri büyütebiliriz:

capitalized metodunu kullandıktan sonra çıktı olarak stringimizdeki tüm kelimelerin baş harfini büyük olarak görebiliyoruz.

3 – Stringleri bağlayarak tek bir String oluşturma yöntemleri:

Swift dilinde stringleri bağlamayı 3 ayrı şekilde gerçekleştirebiliriz.

İlk olarak ekleme yaparak(interpolation) bunu sağlayalım:

Şimdide + operatörünü kullanarak iki stringi birbirine ekleyelim:

Bu şekilde stringleri birbirine ekleyip tek bir string oluşturabiliyoruz, iki string arasına boşluk eklemek istersekte şu şekilde yapabiliriz.

Son olarakta += operatörünü kullanarak bir stringin sonuna diğerini eklemeyi görelim:

Gördüğünüz gibi birlesik3 değişkeni de çıktı olarak “Merhaba Dünya!” vermektedir.

Bu üç yöntemden dilediğinizi kullanarak Stringlerinizi birleştirebilirsiniz 🙂

53 YORUMLAR

  1. Whats up are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started and set up my own. Do you require any html coding expertise to make your own blog? Any help would be really appreciated!

  2. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You obviously know what youre talking about, why throw away your intelligence on just posting videos to your weblog when you could be giving us something informative to read?

  3. hello!,I love your writing very much! percentage we be in contact more approximately your post on AOL? I require an expert in this space to solve my problem. May be that’s you! Taking a look ahead to see you.

  4. It’s actually a great and helpful piece of info. I am satisfied that you simply shared this helpful info with us. Please keep us up to date like this. Thanks for sharing.

  5. great post, very informative. I wonder why the other experts of this sector do not notice this. You must continue your writing. I’m confident, you’ve a great readers’ base already!

  6. Hello very cool blog!! Man .. Excellent .. Superb .. I’ll bookmark your website and take the feeds additionallyKI’m glad to find numerous useful information here in the submit, we’d like work out more techniques in this regard, thanks for sharing. . . . . .

  7. Hello there, just became aware of your blog through Google, and found that it’s really informative. I’m gonna watch out for brussels. I’ll appreciate if you continue this in future. A lot of people will be benefited from your writing. Cheers!

  8. I like the valuable information you supply to your articles.
    I’ll bookmark your blog and take a look at once more right here regularly.
    I am quite certain I will be informed many new stuff right here!
    Good luck for the next!

  9. I’d must check with you here. Which is not one thing I usually do! I enjoy reading a put up that can make folks think. Also, thanks for allowing me to comment!

  10. Great website you have here but I was wondering if you knew of any forums that cover the same topics talked about here? I’d really like to be a part of group where I can get responses from other knowledgeable people that share the same interest. If you have any suggestions, please let me know. Thanks!

  11. I am not sure where you are getting your info, but good topic. I must spend a while studying more or understanding more. Thank you for great information I used to be on the lookout for this information for my mission.

  12. After research a number of of the blog posts on your web site now, and I actually like your method of blogging. I bookmarked it to my bookmark web site listing and shall be checking again soon. Pls try my web site as properly and let me know what you think.

  13. I do not even know how I ended up here, but I thought this post was good. I don’t know who you are but certainly you’re going to a famous blogger if you are not already 😉 Cheers!

  14. Hello there, just became aware of your blog through Google, and found that it’s really informative. I am gonna watch out for brussels. I’ll appreciate if you continue this in future. Lots of people will be benefited from your writing. Cheers!

  15. After examine a number of of the weblog posts in your website now, and I truly like your means of blogging. I bookmarked it to my bookmark web site checklist and will be checking back soon. Pls try my web site as properly and let me know what you think.

  16. I’ve been browsing on-line greater than 3 hours today, but I never found any interesting article like yours. It is beautiful value sufficient for me. In my view, if all website owners and bloggers made excellent content as you did, the net will probably be much more useful than ever before.

  17. I?¦ll right away grasp your rss as I can not in finding your email subscription link or e-newsletter service. Do you have any? Please allow me recognise so that I may just subscribe. Thanks.

  18. Hmm it appears like your website ate my first comment (it was extremely long) so I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still new to everything. Do you have any suggestions for novice blog writers? I’d really appreciate it.

  19. Hi superb website! Does running a blog similar to this require
    a large amount of work? I have absolutely no expertise in coding
    however I had been hoping to start my own blog soon.
    Anyways, should you have any recommendations or techniques
    for new blog owners please share. I know this is off subject however
    I just wanted to ask. Thanks a lot!

  20. I conceive this site has got some real excellent info for everyone. “The individual will always be a minority. If a man is in a minority of one, we lock him up.” by Oliver Wendell Holmes.

  21. Hello, i think that i saw you visited my weblog so i came to “return the favor”.I am attempting to find things to enhance my web site!I suppose its ok to use a few of your ideas!!

BİR CEVAP BIRAK

Lütfen yorumunuzu giriniz
Buraya isminizi giriniz