When I do the call with a string containing only lettere, like yours UIImage(named: "Photos") it works.Thats the equivalent of my working example UIImage(named: "11j".It is when the call is made with a string that contains un emoji. UIImage(named: "J♥") that it does not work.The result of the if let statement returns nil.The name of the image in the Asset folder is "J♥".So it is not a matter of a name that is not copied correctly.
Post
Replies
Boosts
Views
Activity
Sorry, Claude 31, your post did not show up correctly, so I answered it wrong.I tried a simple if let in a small program where it worked , but when pasting the code into my app it did not work.So I'll go back to the drawing board and find the cause elsewhere in the program.Thaks for your help
To get past this problem, I manually recreated the imagesets for the assets. (previously I had copied them from GitHub).This solved the issue. There must have been something wrong with the emoji used in the naming or in the imagefile.
Thank you for your answer/solution.As functional programming is new to me I'm having some difficulty, but your answer showed me some of the logic of the construction.But it also leads me to another question. In the below example (same origin as the previous one) the computation concerns a touple of strings.I'm stuck on the optional part.The tuple is optional.And the validatedPassword is optional.The compiler complains on the guard line that binding must be optional, not String(I assume let pwd = ...).Trying to change password or validatedPassword the compiler rightly complains that that the Publisher is defined as <(String, String?..>.So there is a missing step before the map, and one after ?Is there a recommended way of building the chain of modifiers?I'm not looking as much for a precise solution for this problem, as for a general approach to this kind of problems.And documentation seem to be scare.Do you have any recommendation that might guide me in the right direction ?RegardsLarsPS upgraded to no changeXcode : 11.5 beta1OS : 10.15.5 beta2 Machine : MacMini 201Memory : 32 GO var validatedCredentials: AnyPublisher<(String, String)?, Never> { return Publishers.CombineLatest(validatedUserName, validatedPassword) .map{ (username, password)->(String, String)? in guard let uname = username , let pwd = password else {return nil } return(uname, pwd) } .eraseToAnyPublisher() }
My apologies, your answer worked very well with the validatedUser variable, but my problem is now with the validatedCredentials.Would you have any idea of where the proble is?ThanksLarsXcode : 11.5 beta1OS : 10.15.5 beta2 Machine : MacMini 201Memory : 32 GO var validatedCredentials: AnyPublisher<(String, String)?, Never> { return Publishers.CombineLatest(validatedUserName, validatedPassword) .map{ (username, password)->(String, String)? in guard let uname = username , let pwd = password else {return nil } return(uname, pwd) } .eraseToAnyPublisher() }
I apologize I was wrong with my paste below the good one.It gives me the error message on the guard statement"Initializer for conditional binding must have Optional type, not 'Published<String>.Publisher.Output' (aka 'String')"RegardsLarsXcode : 11.5 beta1OS : 10.15.5 beta2 Machine : MacMini 201Memory : 32 GO var validatedCredentials: AnyPublisher<(String, String)?, Never> { return Publishers.CombineLatest($userName, $password).map { username, password in guard let uname = username, let pwd = password else { return nil } return (uname, pwd) } .eraseToAnyPublisher() }
Thank you very much, and I'll try to read better in the future :-)
I encountered the same problem installing it to an external disk.
However after reformatting the drive in APFS the install hummed on along nicely (It was in Mac Filesystem before)
Hope this helps.
Same problem