conditional binding must have Optional type, not 'String' [duplicate]Conditional Binding: if let error – Initializer for conditional binding must have Optional typeBound value in a conditional binding must be of optional typeConditional Binding: if let error – Initializer for conditional binding must have Optional typeInitializer for conditional binding must have Optional type, not 'NSManagedObjectContextInitializer for conditional binding must have Optional type, not 'String' on HTTPCookieStorageError: Initializer for conditional binding must have optional type, not 'String'“Initializer for conditional binding must have Optional type, not '[String]'”Initialzer for conditional binding must have Optional type not 'String'Firebase update: Initializer for conditional binding must have Optional type, not 'String'iOS Swift: Initializer for conditional binding must have Optional type, not '() -> String?Initializer for conditional binding must have Optional type, not 'NSNumber' in Swift

Entire circuit dead after GFCI outlet

Is using 'echo' to display attacker-controlled data on the terminal dangerous?

Is it possible to have a wealthy country without a middle class?

Someone whose aspirations exceed abilities or means

Why are MBA programs closing?

Ability To Change Root User Password (Vulnerability?)

Electricity free spaceship

Is it a bad idea to to run 24 tap and shock lands in standard

Overlapping String-Blocks

Why 1,2 printed by a command in $() is not interpolated?

How to communicate to my GM that not being allowed to use stealth isn't fun for me?

Teaching a class likely meant to inflate the GPA of student athletes

Is it possible for a vehicle to be manufactured without a catalytic converter?

Determining fair price for profitable mobile app business

Bb13b9 confusion

An easy proof that an isometry preserving the zero vector is linear

Check if three arrays contains the same element

Live action TV show where High school Kids go into the virtual world and have to clear levels

How do you say "homebrewer" in Spanish?

If I leave the US through an airport, do I have to return through the same airport?

Why does Sin[b-a] simplify to -Sin[a-b]?

Why we don’t make use of the t-distribution for constructing a confidence interval for a proportion?

A map of non-pathological topology?

Second (easy access) account in case my bank screws up



conditional binding must have Optional type, not 'String' [duplicate]


Conditional Binding: if let error – Initializer for conditional binding must have Optional typeBound value in a conditional binding must be of optional typeConditional Binding: if let error – Initializer for conditional binding must have Optional typeInitializer for conditional binding must have Optional type, not 'NSManagedObjectContextInitializer for conditional binding must have Optional type, not 'String' on HTTPCookieStorageError: Initializer for conditional binding must have optional type, not 'String'“Initializer for conditional binding must have Optional type, not '[String]'”Initialzer for conditional binding must have Optional type not 'String'Firebase update: Initializer for conditional binding must have Optional type, not 'String'iOS Swift: Initializer for conditional binding must have Optional type, not '() -> String?Initializer for conditional binding must have Optional type, not 'NSNumber' in Swift






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2
















This question already has an answer here:



  • Conditional Binding: if let error – Initializer for conditional binding must have Optional type

    5 answers



I understand that The text property of UILabel is optional, I tried adding an else but i'm not sure what else to add.



productData.product.productName is me getting the name of the product from the database



 if var pName = productData.product.productName //error
self.productName.text = pName


@IBOutlet weak var pName: UILabel!


Initializer for conditional binding must have Optional type, not 'String' is the error I get, It was working I think im not sure where its gone wrong










share|improve this question













marked as duplicate by vadian ios
Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 19:20


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • The error is pretty clear. productData.product.productName is not optional. Why have you tried to unwrap it?

    – Rakesha Shastri
    Mar 24 at 19:14












  • @RakeshaShastri im trying to update the pName label with productName

    – kmnflask
    Mar 24 at 19:26

















2
















This question already has an answer here:



  • Conditional Binding: if let error – Initializer for conditional binding must have Optional type

    5 answers



I understand that The text property of UILabel is optional, I tried adding an else but i'm not sure what else to add.



productData.product.productName is me getting the name of the product from the database



 if var pName = productData.product.productName //error
self.productName.text = pName


@IBOutlet weak var pName: UILabel!


Initializer for conditional binding must have Optional type, not 'String' is the error I get, It was working I think im not sure where its gone wrong










share|improve this question













marked as duplicate by vadian ios
Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 19:20


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • The error is pretty clear. productData.product.productName is not optional. Why have you tried to unwrap it?

    – Rakesha Shastri
    Mar 24 at 19:14












  • @RakeshaShastri im trying to update the pName label with productName

    – kmnflask
    Mar 24 at 19:26













2












2








2


1







This question already has an answer here:



  • Conditional Binding: if let error – Initializer for conditional binding must have Optional type

    5 answers



I understand that The text property of UILabel is optional, I tried adding an else but i'm not sure what else to add.



productData.product.productName is me getting the name of the product from the database



 if var pName = productData.product.productName //error
self.productName.text = pName


@IBOutlet weak var pName: UILabel!


Initializer for conditional binding must have Optional type, not 'String' is the error I get, It was working I think im not sure where its gone wrong










share|improve this question















This question already has an answer here:



  • Conditional Binding: if let error – Initializer for conditional binding must have Optional type

    5 answers



I understand that The text property of UILabel is optional, I tried adding an else but i'm not sure what else to add.



productData.product.productName is me getting the name of the product from the database



 if var pName = productData.product.productName //error
self.productName.text = pName


@IBOutlet weak var pName: UILabel!


Initializer for conditional binding must have Optional type, not 'String' is the error I get, It was working I think im not sure where its gone wrong





This question already has an answer here:



  • Conditional Binding: if let error – Initializer for conditional binding must have Optional type

    5 answers







ios swift






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 19:10









kmnflaskkmnflask

759




759




marked as duplicate by vadian ios
Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 19:20


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by vadian ios
Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 19:20


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • The error is pretty clear. productData.product.productName is not optional. Why have you tried to unwrap it?

    – Rakesha Shastri
    Mar 24 at 19:14












  • @RakeshaShastri im trying to update the pName label with productName

    – kmnflask
    Mar 24 at 19:26

















  • The error is pretty clear. productData.product.productName is not optional. Why have you tried to unwrap it?

    – Rakesha Shastri
    Mar 24 at 19:14












  • @RakeshaShastri im trying to update the pName label with productName

    – kmnflask
    Mar 24 at 19:26
















The error is pretty clear. productData.product.productName is not optional. Why have you tried to unwrap it?

– Rakesha Shastri
Mar 24 at 19:14






The error is pretty clear. productData.product.productName is not optional. Why have you tried to unwrap it?

– Rakesha Shastri
Mar 24 at 19:14














@RakeshaShastri im trying to update the pName label with productName

– kmnflask
Mar 24 at 19:26





@RakeshaShastri im trying to update the pName label with productName

– kmnflask
Mar 24 at 19:26












2 Answers
2






active

oldest

votes


















0














It states that the use of if condition is unnecessary, because the 'productName' is not optional.



You can directly add the value to your label.



self.productName.text = productData.product.productName //Product name is not optional


Optional chaining is used when you try to get a optional value.
For example, if you want to get the text of label then you'll require if condition.



if var text = self.productName.text //Text in label is optional
print(text)






share|improve this answer























  • so how do I updated the label with the productName?

    – kmnflask
    Mar 24 at 19:26











  • Assigning the 'productData.product.productName' to the label will update the 'productName' to it.

    – sinner
    Mar 24 at 19:29











  • so i tried pName = productData.product.productName and i get cannot assign string to UILabel error

    – kmnflask
    Mar 24 at 20:59


















0














It seems like the compiler is complaining that productData.product.productName is NOT an Optional. The if var name = ____ construct only works on Optionals.



If you are testing for a non-empty String, you may want to check the count or isEmpty instead.






share|improve this answer





























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It states that the use of if condition is unnecessary, because the 'productName' is not optional.



    You can directly add the value to your label.



    self.productName.text = productData.product.productName //Product name is not optional


    Optional chaining is used when you try to get a optional value.
    For example, if you want to get the text of label then you'll require if condition.



    if var text = self.productName.text //Text in label is optional
    print(text)






    share|improve this answer























    • so how do I updated the label with the productName?

      – kmnflask
      Mar 24 at 19:26











    • Assigning the 'productData.product.productName' to the label will update the 'productName' to it.

      – sinner
      Mar 24 at 19:29











    • so i tried pName = productData.product.productName and i get cannot assign string to UILabel error

      – kmnflask
      Mar 24 at 20:59















    0














    It states that the use of if condition is unnecessary, because the 'productName' is not optional.



    You can directly add the value to your label.



    self.productName.text = productData.product.productName //Product name is not optional


    Optional chaining is used when you try to get a optional value.
    For example, if you want to get the text of label then you'll require if condition.



    if var text = self.productName.text //Text in label is optional
    print(text)






    share|improve this answer























    • so how do I updated the label with the productName?

      – kmnflask
      Mar 24 at 19:26











    • Assigning the 'productData.product.productName' to the label will update the 'productName' to it.

      – sinner
      Mar 24 at 19:29











    • so i tried pName = productData.product.productName and i get cannot assign string to UILabel error

      – kmnflask
      Mar 24 at 20:59













    0












    0








    0







    It states that the use of if condition is unnecessary, because the 'productName' is not optional.



    You can directly add the value to your label.



    self.productName.text = productData.product.productName //Product name is not optional


    Optional chaining is used when you try to get a optional value.
    For example, if you want to get the text of label then you'll require if condition.



    if var text = self.productName.text //Text in label is optional
    print(text)






    share|improve this answer













    It states that the use of if condition is unnecessary, because the 'productName' is not optional.



    You can directly add the value to your label.



    self.productName.text = productData.product.productName //Product name is not optional


    Optional chaining is used when you try to get a optional value.
    For example, if you want to get the text of label then you'll require if condition.



    if var text = self.productName.text //Text in label is optional
    print(text)







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 24 at 19:13









    sinnersinner

    323112




    323112












    • so how do I updated the label with the productName?

      – kmnflask
      Mar 24 at 19:26











    • Assigning the 'productData.product.productName' to the label will update the 'productName' to it.

      – sinner
      Mar 24 at 19:29











    • so i tried pName = productData.product.productName and i get cannot assign string to UILabel error

      – kmnflask
      Mar 24 at 20:59

















    • so how do I updated the label with the productName?

      – kmnflask
      Mar 24 at 19:26











    • Assigning the 'productData.product.productName' to the label will update the 'productName' to it.

      – sinner
      Mar 24 at 19:29











    • so i tried pName = productData.product.productName and i get cannot assign string to UILabel error

      – kmnflask
      Mar 24 at 20:59
















    so how do I updated the label with the productName?

    – kmnflask
    Mar 24 at 19:26





    so how do I updated the label with the productName?

    – kmnflask
    Mar 24 at 19:26













    Assigning the 'productData.product.productName' to the label will update the 'productName' to it.

    – sinner
    Mar 24 at 19:29





    Assigning the 'productData.product.productName' to the label will update the 'productName' to it.

    – sinner
    Mar 24 at 19:29













    so i tried pName = productData.product.productName and i get cannot assign string to UILabel error

    – kmnflask
    Mar 24 at 20:59





    so i tried pName = productData.product.productName and i get cannot assign string to UILabel error

    – kmnflask
    Mar 24 at 20:59













    0














    It seems like the compiler is complaining that productData.product.productName is NOT an Optional. The if var name = ____ construct only works on Optionals.



    If you are testing for a non-empty String, you may want to check the count or isEmpty instead.






    share|improve this answer



























      0














      It seems like the compiler is complaining that productData.product.productName is NOT an Optional. The if var name = ____ construct only works on Optionals.



      If you are testing for a non-empty String, you may want to check the count or isEmpty instead.






      share|improve this answer

























        0












        0








        0







        It seems like the compiler is complaining that productData.product.productName is NOT an Optional. The if var name = ____ construct only works on Optionals.



        If you are testing for a non-empty String, you may want to check the count or isEmpty instead.






        share|improve this answer













        It seems like the compiler is complaining that productData.product.productName is NOT an Optional. The if var name = ____ construct only works on Optionals.



        If you are testing for a non-empty String, you may want to check the count or isEmpty instead.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 24 at 19:19









        Mike HayMike Hay

        2,5791626




        2,5791626













            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현