|
I was doing day 29 and all was well till i reached "Working with strings". Im unable to understand how to use the methods explained in the chapter(every time i try to trim and output the result in a text view there are some errors) and also the part that they are from uikit but initially from obj-c(what does that even mean?). |
|
UIKit is the older framework for building apps in the Swift programming language that existed before SwiftUI. If you follow the "100 days of Swift" course on this website instead of the "100 days of SwiftUI" course, you will be learning how to use the UIKit framework. Objective-C is the older programming language that has been used for development on apple products before the Swift programming language even existed. I'm not sure what type of error you're getting when you try to trim the characters. Is your app not building? Or does the app crash when you try to type new words into it? It's hard to say without seeing what you are working with. You can share segments of your code in these forums by wrapping your lines of code in triple back-ticks. (Press the key under the escape key on your keyboard 3 times. Move to a new line, then press that same key 3 times again. Then you can paste your code in lines between the two sets of triple back-ticks) |
|
@Fly0strich thanks for the explanation! this is my testing code:
and this:
doesnt do anything. |
|
Ok, a few things here. I don't think you want to be declaring static variables here. So, just remove the static from your variables. Then, you don't need to write However, you will need to make So, you will end up with something like this...
Another problem is that I don't think that |
|
Now, I think I can see what you are trying to make this app do, and there are a few problems with that as well. I assume that you are wanting your list to show a random word from If that is the case, you will need to use Then, you will want to make sure that both of your text options (the name and the word) are included inside of the I used
|
|
Thanks for the reply!
Your explanation was awesome.
but about the thing i was trying to do: i wanted to remove all the whitespace from the |
|
In that case, one way of doing it is to separate the string into an array of words as I described above, but then rejoin them into a single string.
That will remove the spaces, but there may be a more direct way to do it. I'm not sure. |
|
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.