Post

Replies

Boosts

Views

Activity

Video Player: Error if video could not load?
Hey there, I created a video player like this one: https://developer.apple.com/documentation/avfoundation/media_playback_and_selection/creating_a_basic_video_player_ios_and_tvos But if the video file can not load (because of wrong url or missing internet connection) the player is just showing this loading-circle. So there is no information whether the video file can be loaded or not. Is there a way to check if a video file from the internet is available or not? Thanks!
2
0
4.4k
Dec ’20
Simulator background color changed?
Hey there, recently I changed the background color of my simulator by mistake. I typed in a ViewController: ProgressBar.backgroundColor = UIColor.yellow After that the background color of my simulator was yellow 😂. This means all the menus, Control Centre etc. This is a funny issue but now I want to change it to the default. Changing it the same way like above does not work unfortunately. Can someone help me?
4
0
2.4k
Dec ’20
Change value of array in for-loop
Hey there, I have the following problem: When I change the value of an array in a for-loop the array is not saved with this new value. Example: var numbers = [2, 3, 4, 6, 9] let theNumber = 4 print("Numbers old: \(numbers)") for var number in numbers {     if number == theNumber {         print("Numbers are identical")         number = 10         /*save the changed number in array*/     } } print("Numbers new: \(numbers)") The console output is: Numbers old: [2, 3, 4, 6, 9] Numbers are identical Numbers new: [2, 3, 4, 6, 9] So the value of the array is not changed. How to modify the code so that the value of the array is changed? Is there an easy way to do so? Help is very welcome! Thank you!
7
1
11k
Jun ’20
Local video won't play
Hey there, I wanted to play a local video in my app using the Apple introduction (https://developer.apple.com/documentation/avfoundation/media_assets_playback_and_editing/creating_a_basic_video_player_ios_and_tvos ). Unfortunately it is not possible to use a local file for this. Here is my code: @IBAction func playVideo(_ sender: Any) {         guard let path = Bundle.main.url(forResource: "Video", withExtension: "mp4") else {             print("Video file not found")             return         }         let player = AVPlayer(url: path)         let controller = AVPlayerViewController()         controller.player = player         present(controller, animated: true) {             player.play()         }     } Where is the issue? In console I always get the message "Video file not found". I implemented the video file in Assets.xcassets. Help is welcome!
3
0
1.8k
Jun ’20
Shortcut iPad for a button?
Hey there,since there are keyboards for the ipad it makes sense to use shortcuts in your application e.g. for a specific button.In a macOS App I can simply set one in the interface builder but with an iPad iOS app it seems not to be possible that way...Do you know how to add a shortcut to a button (e.g. the button's action should be executed if you press the "return" key on your iPad external keyboard) ?Help would be very welcome!Thanks a lot!
5
0
1.2k
Jun ’20
Local notification: Add option
Hey there,how do I add a option to a local notification that you can click on it (or a button) an it will go to a view of the app which is not the initial view controller?here my code so far:let center = UNUserNotificationCenter.current() var content = UNMutableNotificationContent() content.title = "Title)" content.body = "Body" let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 300, repeats: false) let uuidString = UUID().uuidString let request = UNNotificationRequest(identifier: uuidString, content: content, trigger: trigger) center.add(request) { (error) in [...] }Thanks for helping!
0
0
441
Mar ’20
How to create a login item?
Hey there,I want a macOS app to use a login item. I found this here, but it's a quite old document, difficult to understand, and not executable because of some errors.So do you know a suitable way to implement a login item? Preferably it should be installed itself when the user install the application.Thanks a lot!
3
0
1.7k
Feb ’20
Mac Background Scheduler
Hey there,I wanted to use this to create a background task for my MacOS App.Unfortunately I don't knwo how to insert the code.I createdlet activity = NSBackgroundActivityScheduler(identifier: "com.example.MyApp.work")in AppDelegate and insertactivity.repeats = true activity.interval = 30in applicationDidFinishLaunching() to initialize the values.But where is the right place to insertactivity.schedule() { (completion: NSBackgroundActivityScheduler.CompletionHandler) in // Perform the activity print("Hello World") self.completion(NSBackgroundActivityScheduler.Result.Finished) }in that way that this application will get a background task, which is not stopped if I quit (or leave) the application?Maybe that's an sutpid question but if so it sould be easy to answer ;-)Thanks a lot!
3
0
937
Dec ’19
Timer im background Task not possible?
Hey there,I have an App which should do something in background.So I wrote some code in AppDelegate:func applicationDidEnterBackground(_ application: UIApplication) { print("BackgroundActivity in Delagate") Timer.scheduledTimer(withTimeInterval: 30, repeats: true) { timer in //Do something } else { //Do something different } } }Now, every time if the application enter background I get this error in console:Can't end BackgroundTask: no background task exists with identifier 1 (0x1), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.I tried to fix it with usingDispatchQueue.global(qos: .background).async { self.BackgroundActivity() DispatchQueue.main.async { print("Hello") } }in viewDidLoad() of the initial view controller to start the background task already if the application is in foreground. The tast does not work and when I go to background I get the same error.Anyone an idea what to do?Thanks a lot!
16
0
13k
Dec ’19
Odd and Even numbers % does not work
So usually you can this here to compare Even and Odd numbers:if checking % 2 == 0 { print("Even number") } else { print("Odd number") }But I get this error and don't know what excactly to do:'%' is unavailable: For floating point numbers use truncatingRemainder insteadAnyone an idea what to do? What is tuncatingRemainder ... ?Thanks!
3
0
2.2k
Dec ’19