Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a problem with youtube duration.
How to separate this string:
PT1H50M20S
to 1:50:20 with NSRegularExpression.
No need to use NSRegularExpression here, you can use NSCharacterSet instead.
let s = "PT1H50M20S"
s.componentsSeparatedByCharactersInSet(NSCharacterSet.letterCharacterSet())
.filter { $0 != "" }
.joinWithSeparator(":") // 1:50:20
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 19 hours ago.
Improve this question
I am trying to develop an app that shows a trip on a map from a list of trips.
I have a list of trips in a bottom sheet and when I click on one of these I would like to update the map showing the information of the trip (the tripPoints on the map).
struct Trip {
let id: String
let tripPoints: [TripPoints]
}
struct TripPoints {
let id: String
let latitude: CLLocationDegrees
let longitude: CLLocationDegrees
}
I tried to use a variable selectedTrip that I update everytime i click on one of the trip, but the map doesn't update.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last year.
Improve this question
How can I make a check for the correctness of the entered data?
For example, the user needs to enter a digit, and until this is done, the program will not skip it further
In my case, you need to make sure that the user entered an integer, and not a string, double, etc.
Just create an infinite loop. If your read is successful break it. Something like:
while true {
if let line = readLine(), let value = Int(line) {
print("value", value)
break
}
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm creating a desktop app with Swift and I need to pass a stop boolean after 5 seconds. How do I do this?
You can use asyncAfter to create an async delay. After the 5.0 seconds you can do what you want.
var stop: Bool = false
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) { // runs after 5.0 seconds
// pass your stop boolean here
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Very strange issue.
I have the following code:
NSDictionary* notificationUserInfo = [pNotification userInfo];
NSManagedObject* newShoppingFilter = [notificationUserInfo valueForKey:#"shoppingListFilter"];
self.shoppingListFilter = newShoppingFilter;
NSLog(#"%# tapped", [newShoppingFilter valueForKey:#"name"]);
For some reason the self.shoppingListFilter = newShoppingFilter is not setting the variable.
I assume that this is some issue with not initializing the self.shoppingListFilter variable in some way but I cannot figure this out. The NSLog shows the right output, newShoppingFilter is not null but self.shoppingListFilter is.
Any help is appreciated.
I bet newShoppingFilter is nil. Most likely, there is no key "shoppingListFilter" in the notification user info dictionary.
Set a breakpoint at the line that assigns a value to self.shoppingListFilter and check the value of newShoppingFilter. Also display the entire contents of notificationUserInfo.
Post the code that creates the user info dictionary and passes it into the notification that you are posting. That would help track down the problem.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
How could I write this in real code?
if (!UIImageView with origin.x > 50.0) {
//Exlcude the imageview from whatever happens in this statement.
}
if (imageView.frame.origin.x <= 50.0) {
// The code in this block won't bother the image views
// with 'x > 50.0' anymore
}