Click here to Skip to main content
14,271,874 members
   

iOS

 
PinnedPLEASE READ: How to get an answer to your question Pin
Chris Maunder13-Jan-15 15:36
adminChris Maunder13-Jan-15 15:36 
QuestionMessage Closed Pin
13-Aug-19 10:46
memberMember 1455618813-Aug-19 10:46 
QuestionHow do I unwrap an optional within a struct and use an if statement to print the optional? Pin
WilliamChen724-Jul-19 8:06
memberWilliamChen724-Jul-19 8:06 
I am getting an error message for my use of nil and I am confused on how to properly unwrap the optional while placing it in an if statement to print out a string.



struct DatingProfile{
      var Name: String
      var Age: Int
      var City: String
      var FavoriteMovie: String? 
      var Hobbies: String?
     
    }
    
    let myDatingProfile = DatingProfile(Name: "William", Age: 30, City: "North Hollywood", FavoriteMovie: nil , Hobbies: "Basketball")
    
    if let myFavoriteMovie = FavoriteMovie = nil{
      print("\(Name) does not have a favorite movie")
       
    }else {
      
        print(myDatingProfile.FavoriteMovie)
      }
      
    }


exit status 1
main.swift:12:26: error: use of unresolved identifier 'FavoriteMovie'
if let myFavoriteMovie = FavoriteMovie = nil{
^~~~~~~~~~~~~
main.swift:13:12: error: use of unresolved identifier 'Name'
print("\(Name) does not have a favorite movie")
^~~~
main.swift:17:11: warning: expression implicitly coerced from 'String?' to 'Any'
print(myDatingProfile.FavoriteMovie)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.swift:17:27: note: provide a default value to avoid this warning
print(myDatingProfile.FavoriteMovie)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
?? <#default value#>
main.swift:17:27: note: force-unwrap the value to avoid this warning
print(myDatingProfile.FavoriteMovie)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
!
main.swift:17:27: note: explicitly cast to 'Any' with 'as Any' to silence this warning
print(myDatingProfile.FavoriteMovie)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
as Any
main.swift:20:1: error: extraneous '}' at top level
}
^
AnswerRe: How do I unwrap an optional within a struct and use an if statement to print the optional? Pin
Richard Deeming24-Jul-19 9:32
mveRichard Deeming24-Jul-19 9:32 
QuestionHow to remove MDM profile installed on 2018 iPad Pro 256GB model? Pin
TovinoThomas11-Jun-19 20:45
memberTovinoThomas11-Jun-19 20:45 
AnswerRe: How to remove MDM profile installed on 2018 iPad Pro 256GB model? Pin
Richard MacCutchan11-Jun-19 21:08
protectorRichard MacCutchan11-Jun-19 21:08 
QuestioniOS vs Android, what made you pick iOS? Pin
TovinoThomas11-Jun-19 20:45
memberTovinoThomas11-Jun-19 20:45 
QuestionI try to create a path between two planets, I have no compilation error but I do not understand why there is nothing that appears on my simulator Pin
Member 1419771526-Mar-19 3:55
memberMember 1419771526-Mar-19 3:55 
Questionxamarin forms cropping in ios Pin
Member 141415896-Feb-19 4:04
memberMember 141415896-Feb-19 4:04 
QuestionAzure Devops not creating IPA file for Xamarin iOS build Pin
Dominic Burford5-Oct-18 0:30
professionalDominic Burford5-Oct-18 0:30 
Questionplease help translate objc c to swift Pin
Member 118295143-Jun-18 7:21
memberMember 118295143-Jun-18 7:21 
QuestionSoap-swift Pin
Member 135476754-Dec-17 0:27
memberMember 135476754-Dec-17 0:27 
AnswerMessage Closed Pin
6-Jul-18 10:17
grouppv4799536-Jul-18 10:17 
QuestioniOS app crashes on startup Pin
Member 133472715-Aug-17 0:19
memberMember 133472715-Aug-17 0:19 
QuestionRe: iOS app crashes on startup Pin
David Crow6-Aug-17 9:39
memberDavid Crow6-Aug-17 9:39 
AnswerRe: iOS app crashes on startup Pin
Terry Perez14-Sep-17 6:02
memberTerry Perez14-Sep-17 6:02 
AnswerMessage Closed Pin
7-Jun-18 13:00
memberprosmpeter7-Jun-18 13:00 
QuestionIs there website to make free ios apps? Pin
Satbeer Singh7-Apr-17 1:42
memberSatbeer Singh7-Apr-17 1:42 
SuggestionRe: Is there website to make free ios apps? Pin
CHill607-Apr-17 1:43
protectorCHill607-Apr-17 1:43 
GeneralMessage Closed Pin
25-Mar-19 1:41
professionalMember 1419522825-Mar-19 1:41 
AnswerRe: Is there website to make free ios apps? Pin
Richard MacCutchan7-Apr-17 2:48
protectorRichard MacCutchan7-Apr-17 2:48 
GeneralRe: Is there website to make free ios apps? Pin
Satbeer Singh7-Apr-17 4:24
memberSatbeer Singh7-Apr-17 4:24 
GeneralRe: Is there website to make free ios apps? Pin
Richard MacCutchan7-Apr-17 4:42
protectorRichard MacCutchan7-Apr-17 4:42 
AnswerRe: Is there website to make free ios apps? Pin
Surya_Narayan10-Apr-17 23:36
professionalSurya_Narayan10-Apr-17 23:36 
GeneralRe: Is there website to make free ios apps? Pin
Satbeer Singh11-Apr-17 23:43
memberSatbeer Singh11-Apr-17 23:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.