Custom function return is not a correct value

Hello

I have a code to create my own function, but it gives me a warning:

-Incompatible integer to pointer conversion assigning to ' SMUserKey *' (aka ' unsigned long *') 'int '.

-Incompatible integer to convert pointer sending 'SMUserKey' (aka 'unsigned' long) to the type parameter ' SMUserKey *' (aka ' unsigned long *')

When I change NSString * result = [SMUser getValueForKey:SMUsername]; to NSString * result = [SMUser getValueForKey:SMEmail];  and then run the application, it will always record "Username". Must be in place.

This is my code .h:

typedef NSUInteger SMUserKey;

{NS_ENUM (SMUserKey)}

SMUsername = 1,

SMFirstName = 2,

SMLastName = 3,

SMFullName = 4,

SMEmail = 5,

};

It's my ".m" code:

-awakeFromNib (void) {}

NSString * result = [SMUser getValueForKey:SMUsername];

NSLog (@"THE RESULT: % @", result);

}

+ (NSString *) getValueForKey:(SMUserKey*) myUserKey {}

NSString * myUserKeyValue = nil;

If ((myUserKey = 1)) {}

myUserKeyValue = @ "Username";

}

If ((myUserKey = 2)) {}

myUserKeyValue = @ "First Name";

}

If ((myUserKey = 3)) {}

myUserKeyValue = @ "Last Name";

}

If ((myUserKey = 4)) {}

myUserKeyValue = @ "full name";

}

If ((myUserKey = 5)) {}

myUserKeyValue = @ "Email."

}

Return myUserKeyValue;

}

This is the picture showing the warnings:

The reason why you got warnings in the case of statements is that you assign the myUserKey variable the values 1 to 5 instead to compare the variable to these values, which is what you expect to happen. The = operator assigns values. The statement myUserKey = 1 myUserKey gives the value 1. Him == operator compares two values for equality. Education myUserKey == 1 checks if myUserKey is equal to 1. Adding a supplement of equal sign on each condition in the condition statements do the warnings go away.

Tags: iOS Developer

Similar Questions

  • How to have a variable the function "return" have more than one value

    @using the Sub function how can user_id accepts the values 0 and 6?

    create or replace function xxactive_user_test)

    p_schema in varchar2,

    p_object in varchar2)

    return varchar2

    as

    Start

    return 'user_id = 0';

    end;

    /

    Post edited by: 880492

    The question or needs is not clear, to me at least.

    > How user_id can take the values 0 and 6

    How the function is used.

    You mean like this:

    return 'user_id IN (0,6)';
    
  • Control the output is not the correct value

    Hello

    I have a producer consumer with a queue architecture to pass values. I want to push a new value in the table by using "Insert table" when a button is pressed, but when I do the previous value is read the first time and the correct value on the second press.

    I am self-taught and this is my first time using the queue so maybe something I'm not seeing/thinking about here?

    Version 8 attached VI.

    To see the problem, follow these steps:

    1. run
    2. click on "master reading.
    3. change the 'value '.
    4. click on "master reading.
    5. click on "master reading.

    Any help is appreciated especially block critical diagram.

    Thank you!

    It all depends on how you change the value of 'value. ' If you use the increment and decrement buttons it works as expected.

    If however, you type a new value and click the button without clicking elsewhere first, it does not - and here's why:

    When you type a modified value value does not appear in the code until the control loses "touch focus". The problem is that clicking the button causes the digital input to lose key focus, but only after the code responded to the mouse event.

    To solve the problem put a property node in the supported mouse event to set the property KeyFocus the digital to false until the value is queued.

    Mike...

  • Compressed file (zipped problem)! Failed to open due to the "open with..." function. "do not set correctly.

    I'm having a problem with compressed (zipped) folders. I'm unable to create brand new. Maybe it's because the function "open with...". "for compressed (zipped) folders is not set correctly, they still appear as programs Adobe instead of compressed files, which makes them unable to open or run. How can I use "open with...". "to open the files compressed as compressed folders? I'd appreciate any help I can get. Thank you.

    File association fixes MVP Ramesh - includes .zip
    http://www.Winhelponline.com/articles/105/1/file-association-fixes-for-Windows-Vista.html MS - MVP - Elephant Boy computers - don't panic!

  • Satellite C660 - function keys do not work correctly

    I have a strange problem with the help of function keys. When I turn on the laptop the functions work well. However, after 30 seconds of standing on the desk, they stop. The only buttons fuction that work after that are for the volume (up and down). The brightness, the mute button, they all stop working.

    I have no idea what is the reason for this and I'll be happy to have your help.

    MODEL NAME: Toshiba Satellite C660-1MU
    PART NO.: PSC1SE-00600283
    OS: Windows 8.1

    As far as I know, function keys are controlled by the driver of Toshiba system and key function Toshiba utility and they must be active in the background (to start).
    I checked the Toshiba download page, and as I can see, your laptop is not yet supported for Win8.1. What drivers you have installed?

    Anyway, you can try to reinstall them.

  • Function key does not work correctly

    After a dramatic fall of the hard drive, I need to change with another.

    I used system restore downloaded to a usb and everthing worked prperly except the fn key which opens not menu with touches of gray.

    in for example. I can't Turn off wi - fi device. can someone help me?

    Thanks a lot for now.

    PS I apologize for my poor English so I ask if it is possible to answer esily or better in Italian.

    May I ask what model phone you have and what Windows system is currently pre-installed?

  • Customs add captions are not displayed correctly

    Hello

    The default captions in Breeze have a minimun height that is often times too large. If I have one of these files BMP resize and save a copy, everything works fine and I have a new legend with a reduction of the minimum size.

    What about new legends. Seems easy, create a file in a drawing program such as Photoshop, make a custom legend and save a BMP file. However, once you add it to your project, you get nothing. Why should I get new legends? Well, I need an image that lives on a screen to disappear when I want it. So, I want to put a legend of big WHITE reversal over the image when the user moves the mouse in a certain area. Oh, the movie is paused.

    Help!

    Thank you lisa what would you say of new legends. What would you say of new legends.

    Wow,

    I found a solution! I think that if I use a click instead of a rollover caption box, I will be able to use the Captivate timeline to do what I want. The only draw back is that the learner can access information only once when they click, because they cannot go back in time or a specific image.

    The only other way to solve this problem is to perform the interaction across multiple slides where I have duplicate information.

    Lisa

  • Function does not return the correct value

    Hi, I'm having a strange problem and hope someone knows how to solve this problem...

    I try to send a string to a function in another class and do return to a textfield, so I can add it to a movieclip and on the stage. I use it for several buttons. The problem is when I put that a string in it value returns a string for the previous call to the function that is not the string value that I want to use. Here's the function:

    public void replaceMCTxt (mcString:String, xPos:Number,

    yPos:Number, rolloverText:Boolean, newFontSize:uint, height: uint, width: uint = false): {TextField

    var newMCTxt:TextField = new TextField();

    newMCTxt.x = xPos;

    newMCTxt.y = yPos;

    newMCTxt.width = width;

    newMCTxt.height = Height;

    var textFormat:TextFormat = new TextFormat();

    textFormat.align = _gameModel.screenFontAlign;

    textFormat.size = newFontSize;

    textFormat.font = _gameModel.screenFont;

    textFormat.color = _gameModel.screenFontColor;

    newMCTxt.defaultTextFormat = textFormat;

    newMCTxt.text = _languageClass.getTranslation (mcString);

    newMCTxt.selectable = false;

    Return newMCTxt;

    }

    I try to call with this statement in another class:

    _moreGamesTxtField = _updateLanguageClass.

    ("MORE GAMES", _gameModel.moreGamesTxtXPos, replaceMCTxt

    _gameModel.moreGamesTxtYPos, _gameModel.moreGamesTxtWidth,

    (_gameModel.moreGamesTxtHeight, _gameModel.moreGamesTxtFontSize);

    Instead of giving me a movieclip "MORE GAMES", it gives me a 'PLAY' movieclip, which is what the previous call to the function used. I also had a similar problem in another function where he did the same thing with filtering of different buttons, so I think the problem is in the service, but I'm not programmer to know that it's good enough. If anyone has an idea please let me know. Thank you...

    Start the survey using the trace() function to see what value is passed to and returned by some _languageClass.getTranslation ().

  • ODDM 4.1.1.888 transform script function getProperty() does not return NOT NULL;

    Hello

    In the 4.0.0.833 version the funcion getProperty() returns NULL when the dynamic propertyare not out,

    e.g. VRFDA = table.getProperty ("Text"); -Returns a null value if the dynamic property 'Text' does not exist. The Variable VRFDA is nothing

    I have version 4.1.1.888 and the GetFilter() function returns DO NOT null when the dynamic property does not exist.

    Could you tell me what value returns the GetFilter() function when the dynamic property does NOT exist?


    Thank you

    In version 4.1 the getProperty function will return an empty string if the dynamic property does not exist.

    David

  • Function key does not work do not

    Recently I bought HP 15R laptop 036TU. Function keys do not work correctly. As if, press F2 it adjusts the brightness rather than change the name of the folder. PL suggest what parameter changes are required. Thanks, Nitin.

    Hello

    Please follow the instructions below:

    http://support.HP.com/us-en/document/c02035108

    You may need to use the ESC key on the step #2 (if F10 does not work).

    Kind regards.

  • Statistical analysis return do not correct values

    I play on two tables 1 d of statistical analyses. I send you these tables as input for each of the statistical analysis screw the thing is that when I check with other stat software, I get different values, so I have to do something wrong.

    Can someone please?

    Thank you.

    I agree with Martins, that it is not extremely difficult to see what you do with this code and to "check" the statistical results returned by LabVIEW are 'bad '.  I note that you also asked that LabVIEW gave the results of 'bad' when you use an array of numbers, but I am absolutely the correct values when I tried a (very simple) example using the features you said 'bad '.

    Is it possible that LabVIEW is, indeed, to give correct results, but you do not understand the statistics concerned, or is not a good understanding of the input being analyzed data?

    I strongly recommend that you write the simple sample code, known (and easy) data entry to examine the results of the statistical routines LabVIEW.  I suspect you'll (probably) find that they give the correct answer.  If you do find a gap and have a simple example to show us, we will be (of course) very interested...

    Bob Schor

  • Works do not return correct value

    Hello

    I have a function that is passed into a work of identification.  The function will be watching the ID for this work and compare them to a table.  If at least 1 id does not exist in this table, I need the function returns 0.  If each id exists, so I want to back a 1.  I thought I had work because he worked in a few tests, but it does not work for the current situation.

    create or replace FUNCTION JOB_CHECK
    (  
      P_JID IN NUMBER  
    )
    RETURN NUMBER
    AS
      VSTRING CLOB ;  
      TABV UTL.TYPWORDS ;  
      NCHECK NUMBER := 1 ;
    BEGIN
      SELECT VID INTO VSTRING FROM WorkJOBS WHERE JID=P_JID ;   
      TABV := UTLPKG.SPLIT(VSTRING) ;
        
      FOR I IN TABV.FIRST..TABV.LAST LOOP    
        SELECT 1 INTO NCHECK FROM JOBS_LIST WHERE VID = TABV(I) ;         
        RETURN NCHECK;
      END LOOP ;
      
      EXCEPTION
        WHEN NO_DATA_FOUND THEN
          RETURN 0 ;
    END JOB_CHECK ;
    

    What's happened is that we removed our job_list table IDS then any work which is verified with an old ID I want to report.

    Thank you.

    At least put the oudside loop back:

    END LOOP;

    RETURN NVERIFIEZ;

  • Function return undefined values

    My function returns undefined values. It seems that the return of the function statement is executed before the database is queried and values are assigned to variables. If I do an alert within the loop for () I get the correct values from the database, but these values are not affected before excecuting the return statement function. How can I do this differently?

    function getColumnNames(table){
        var rs1, rs2, rs3, rs4, rs5;
        db.transaction(function (tx) {
            tx.executeSql("SELECT * FROM schema WHERE table_name=?",[table], function(ax, results){
                var size = results.rows.length, i;
                var item;
                for (i = 0; i < size; i++){
                    item = results.rows.item(i);
                    rs1 = item.col1;
                    rs2 = item.col2;
                    rs3 = item.col3;
                    rs4 = item.col4;
                    rs5 = item.col5;
                                    alert(rs1); //correct value is returned here
                }
            });
        });
        return [rs1, rs2, rs3, rs4, rs5];
    }
    

    Hey Fabian,.

    You are quite correct that the return statement is executed before the database returns the results. There are ongoing asynchronous calls. You can set breakpoints in JavaScript code to see what is happening. You can correct the problem by using function callbacks. I edited your code below to use the callback functions - there might be a few typos, but the general approach should be wooded.

    function getColumnNames(table, callback){
        var rs1, rs2, rs3, rs4, rs5;
        db.transaction(function (tx) {
            tx.executeSql("SELECT * FROM schema WHERE table_name=?",[table], function(ax, results){
                var size = results.rows.length, i;
                var item;
                for (i = 0; i < size; i++){
                    item = results.rows.item(i);
                    rs1 = item.col1;
                    rs2 = item.col2;
                    rs3 = item.col3;
                    rs4 = item.col4;
                    rs5 = item.col5;
                        alert(rs5); //correct values are being returned
                    callback([rs1, rs2, rs3, rs4, rs5]);
                }
            });
        });
    }
    
    // example of how to call getColumnNames with callback
    getColumnNames('importantTable', function (result)
    {
        console.log(result);
    });
    
    // alternative version
    function onCallback(result)
    {
        console.log(result);
    }
    
    getColumnNames('importantTable', onCallback);
    

    I hope this helps.

    See you soon,.

    James

  • Autodesk DWF Writer 3.1 is not installing from the windows machine 7. Error returned is "failed reading registry value DriverCachePath".

    Product name: Autodesk DWF Writer 3.1

    OS: Windows 7

    Error: failure reading registry value DriverCachePath

    Error is not occurring in all machines of widows 7

    Thanks in advance.

    Please help to install

    Hello

    The computer is on a domain?

    Will correct the problems with programs that cannot be installed or uninstalled method 1)

    http://support.Microsoft.com/mats/Program_Install_and_Uninstall/

    If the problem persists, try to install the clean boot

    Method 2) how to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    http://support.Microsoft.com/kb/929135

    Note: When you perform a clean boot, you temporarily lose some functionality. When you start the computer as usual, the function returns. However, you may receive the error message, or you can experience the original behavior. Don't forget to reset the computer in Normal mode.

    It may be useful

  • ORA-06503: PL/SQL: function returned no value ORA-06512:

    Hi all

    SQL > set serveroutput on

    SQL > CREATE OR replace FUNCTION qty_value (p_item_id number)

    2 RETURN NUMBER

    3 EAST

    4 v_qty_arrival NUMBER;

    5 BEGIN

    6. SELECT THE CASE SENSITIVE OPTION

    7. WHAT (SUM (b.quantity) - SUM (b.quantity_received)) < = 0 THEN 0

    8 ELSE (SUM (b.quantity) - SUM (b.quantity_received))

    9 END Qty_Arrival

    10 INTO v_qty_arrival

    Po_lines_all 11 a,

    po_line_locations_all 12 b

    13 WHERE a.po_line_id = b.po_line_id

    14 AND a.item_id = p_item_id;

    15 EXCEPTION

    16 THEN THAN OTHERS THEN

    17 v_qty_arrival: = NULL;

    18 RETURN v_qty_arrival;

    19 END qty_value;

    20.

    The function is created.

    SQL >

    SQL > select xxc_qty_arrivale (214960) double

    2.

    Select xxc_qty_arrivale (214960) double

    *

    ERROR on line 1:

    ORA-06503: PL/SQL: function returned no value

    ORA-06512: at the 'APPS '. XXC_QTY_ARRIVALE', line 19

    Back AFTER using the exception block is fine as long as your code actually REACHED the exception block.

    When there are no errors, then your code will not enter the exception block, but you still NEED to return a value, since it is what functions a function wants to return a value, that's what the functions are made for.

    Spot the differences between the following 3 functions. Understand how they work.

    The first function has only a return in the exception block but runs correctly. Result: error, because the back is missing in the code block.

    The second function has a return in the exception block and one in the block of code and runs correctly. Result: no error, because the return is not missing in the code block.

    The third function has a return in the exception block and one in the block of code and is forced into an error. Result: no error, because the return of the exception handler is used (instead of retriggering of the error, which you would normally do).

    SQL > create or replace function myfunc

    2 return number

    3 as

    4 start

    5 dbms_output.put_line ('in the section of code');

    6 null;

    7 exception

    8 then than others

    9. can

    10 dbms_output.put_line (' in the exception handler ' |) SQLERRM);

    11      --

    12 return 0;

    13      --

    14 end;

    15.

    The function is created.

    SQL > select double myfunc;

    Select double myfunc

    *

    ERROR on line 1:

    ORA-06503: PL/SQL: function returned no value

    ORA-06512: at "GHPLUS. MYFUNC", line 14

    In the section of code

    SQL > create or replace function myfunc

    2 return number

    3 as

    4 start

    5 dbms_output.put_line ('in the section of code');

    6 null;

    7    --

    8 return 1;

    9    --

    10 exceptional

    11 so that others

    12. can

    13 dbms_output.put_line (' in the exception handler ' |) SQLERRM);

    14      --

    15 return 0;

    16      --

    end 17;

    18.

    The function is created.

    SQL > select double myfunc;

    MYFUNC

    ----------

    1

    1 selected line.

    In the section of code

    SQL > create or replace function myfunc

    2 return number

    3 as

    n number 4;

    5. start

    6 dbms_output.put_line ('in the section of code');

    7 n: = 1/0; -force an error (zero divisor) to join the exception handler

    8    --

    9 return 1;

    10-

    exception 11

    12 so that others

    13. can

    14 dbms_output.put_line (' in the exception handler ' |) SQLERRM);

    15      --

    16 return 0;

    17      --

    18 end;

    19.

    The function is created.

    SQL > select double myfunc;

    MYFUNC

    ----------

    0

    1 selected line.

    In the section of code

    In the handler for exception ORA-01476: divisor is equal to zero

    SQL >

Maybe you are looking for