Incompatible types in assignment

Hello everyone,
I'm quite new to objective-c programming. So far, i pretty much solved everything either on my own with the documentation, and with some googling. One problem i haven't solved was how to detect a swipe on a uiscrollview, but i thought i found another way to do it.
However, when i'm trying to get the contentoffset.x of my scrollview (named dayScrollView) and store it in a CGFloat, i get a compiler error ' incompatible types in assignment'. I have been able to access it just fine, however now it's giving me trouble.
I declared the float in the header file (CGFloat *deceleratingTouch), and then tried to store it in the implementation file (deceleratingTouch=dayScrollView.contentOffset.x;). What is possible that went wrong? as i said, i'm quite new, so i sometimes make the stupidest mistakes.

Ok, it was solved. Apparently, CGFloat doesn't need the asterisk if you declare it in the header file. That's what i said about stupid mistakes

Similar Messages

  • Incompatible Types in Assignment for CGPoint

    hey i'm new to this and i'm not sure why i keep getting this problem.
    TrainerViewController.h file:
    #import <UIKit/UIKit.h>
    @interface TrainersViewController : UIViewController {
    IBOutlet UIButton *upMovementButton;
    IBOutlet UIButton *downMovementButton;
    IBOutlet UIButton *leftMovementButton;
    IBOutlet UIButton *rightMovementButton;
    IBOutlet UIButton *jumpMovementButton;
    IBOutlet UIImageView *character;
    CGPoint *characterVelocity;
    NSTimer *_moveLeft;
    NSTimer *_moveRight;
    NSTimer *_moveJump;
    @property(nonatomic,retain) IBOutlet UIButton *upMovementButton;
    @property(nonatomic,retain) IBOutlet UIButton *downMovementButton;
    @property(nonatomic,retain) IBOutlet UIButton *leftMovementButton;
    @property(nonatomic,retain) IBOutlet UIButton *rightMovementButton;
    @property(nonatomic,retain) IBOutlet UIButton *jumpMovementButton;
    @property(nonatomic,retain) IBOutlet UIImageView *character;
    @property(nonatomic) CGPoint *characterVelocity;
    @property(nonatomic,retain) NSTimer *_moveLeft;
    @property(nonatomic,retain) NSTimer *_moveRight;
    @property(nonatomic,retain) NSTimer *_moveJump;
    - (IBAction)characterMoveRightStart;
    - (IBAction)characterMoveRightStop;
    - (IBAction)characterMoveLeftStart;
    - (IBAction)characterMoveLeftStop;
    @end
    TrainersViewController.m file:
    #import "TrainersViewController.h"
    #define gravityAcceleration 1
    #define characterSpeedX 10
    #define characterSpeedY 15
    @implementation TrainersViewController
    @synthesize character,leftMovementButton,rightMovementButton,downMovementButton,upMovementButton,jumpMovementButton,moveLeft,_moveRight,moveJump;
    @synthesize characterVelocity;
    - (void)viewDidLoad {
    [super viewDidLoad];
    characterVelocity = CGPointMake(characterSpeedX, characterSpeedY);
    /*[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES];*/

    CGPointMake return a CGPoint while characterVelocity is of type CGPoint*, one is a struct the other is a pointer.

  • [SOLVED] XSD simpleType trying to assign incompatible types

    Hi all!
    I have a big XSD schema with complex and simple types defined. One of the simple types looks like this (string with min and max length defined):
         <xsd:simpleType name="MySimpleType">
              <xsd:restriction base="xsd:string">
                   <xsd:minLength value="1" />
                   <xsd:maxLength value="36" />
              </xsd:restriction>
         </xsd:simpleType>I assign (copy operation) a string variable to an element of this type. When I compile i get the trying to assign incompatible types warning. I know it's just a warning but I'd like to solve it. I thought I can create a variable of the same type, but I can't (if I try to define message type only the complex type from XSD are displayed).
    Is there a way to get rid of this warning?
    Thanks

    instead of using a variable assignment use the expression builder to construct the 'bpws:getVariableData() equivalent of the variable assignment. The warning will no longer exist.

  • ORABPEL-10041 Trying to assign incompatible types

    Hi,
    I'm developing a BPEL process which takes an input xml file and inserts data into AP interface tables. I used a file adapter to read the input file and used applications adapter to import ap interface tables.
    I use the assign activity to assign the number value from my xml file to the invoice_id column in the ap_invoices_interface column. I get the following warning. Can anyone please tell me how do I fix this. I have BPEL 10.1.2.2 installed.
    Warning(29):
    [Error ORABPEL-10041]: Trying to assign incompatible types
    [Description]: in line 29 of "C:\OraBPELPM_1\integration\jdev\jdev\mywork\Workspace1\BPELProcess_TestInsert\BPELProcess_TestInsert.bpel", <from> value type "{http://www.w3.org/2001/XMLSchema}string" is not compatible with <to> value type "{http://www.w3.org/2001/XMLSchema}long".
    [Potential fix]: Please make sure that the return value of from-spec query is compatible with the to-spec query.
    Thanks

    This is just a warning so it does not mean that your process will fail, e.g. string to decimal may work for the string holds a number, but will fail if it has a string.
    So if you know the data you can safely ignore, otherwise you will have to do some transofrmation within an assign.
    cheers
    James

  • Incompatible types - found java.lang.String but expected int

    This is an extremely small simple program but i keep getting an "incompatible types - found java.lang.String but expected int" error and dont understand why. Im still pretty new to Java so it might just be something stupid im over looking...
    import java.io.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class Lab
    public static void main(String []args)
    int input = JOptionPane.showInputDialog("Input Decimal ");
    String bin = Integer.toBinaryString(input);
    String hex = Integer.toHexString(input);
    System.out.println("Decimal= " + input + '\n' + "Binary= " + bin + '\n' + "Hexadecimal " + hex);
    }

    You should always post the full, exact error message.
    Your error message probably says that the error occurred on something like line #10, the JOptionPane line. The error is telling you that the compiler found a String value, but an int value was expected.
    If you go to the API docs for JOptionPane, it will tell you what value type is returned for showInputDialog(). The value type is String. But you are trying to assign that value to an int. You can't do that.
    You will need to assign the showInputDialog() value to a String variable. Then use Integer.parseInt(the_string) to convert to an int value.

  • Problem with incompatible types

    Can you help me out where the problem is? The Child extends the Iterator<GenericTypeTest> so why the assignment doesn`t work? Thank you in advance
    class GenericTypeTest implements Iterator<GenericTypeTest> {
        public GenericTypeTest() {
            Child a = null;
            Iterator<GenericTypeTest> b = null;
            b = a;
            Set<Child> sa = null;
            Set<Iterator<GenericTypeTest>> sb = null;
            sb = sa; // HERE: COMPILATION PROBLEM
            // (Incompatible types: found: Set<Child> required: Set<Iterator<GenericTypeTest>>)
        public boolean hasNext() {
            return false;
        public GenericTypeTest next() {
            return null;
        public void remove() {
    class Child extends GenericTypeTest {}

    You can only assign from a subtype to a supertype. And the subtype/supertype relationship for generic types isn't what you think it is. Read this FAQ entry for more information, especially the part around the sentence "The prerequisite is that at least one of the involved type arguments is a wildcard."

  • Incompatible types error on a for loop

    Hi. I am in the middle of making a program and a decided to make a print statment to check to make sure everything was organized as it should be and I got an incompatible types error for the line where I start my for loop - for (index = 0 ...) etc. Since everything is an int, I'm not sure how they're not compatible with each other.. thoughts? here's my code so far, thanks
    import java.io.*; // needed for stream readers
    import java.lang.*;
    public class testScores extends Object
         public static void main(String args[] ) throws Exception
         // declare variables for input
    String      records;
    String      room_nbr_input;
    String      test_score_input;
    String      student_id;
    int          room_nbr_nbr;
    int          test_score_nbr;
    int          index;
    String[] record = new String[3];
    int[]     room_nbr = new int[30];
    int[]      test_score = new int[30];
    int[]     kount = new int[30];
         // created file reader and buffered reader
              FileReader frM;
              BufferedReader brM;
              // open file
              frM = new FileReader("einstein_testscores_2009.txt");
              brM = new BufferedReader(frM);
         // print headings
              startUp();
              // get one record from file
              records = brM.readLine();
              while(records !=null)
              //split the record into three fields = the array record[], then assign those values to variables
              record = records.split(", ");
              student_id = record[0];
              room_nbr_input = record[1];
              test_score_input = record[2];
              //change the data into integers
              room_nbr_nbr = Integer.parseInt(room_nbr_input);
              test_score_nbr = Integer.parseInt(test_score_input);
              //put the variables into arrays
              room_nbr[room_nbr_nbr -1] = room_nbr_nbr;
              test_score[room_nbr_nbr -1] = test_score[room_nbr_nbr -1] + test_score_nbr;
              //get new record
              records = brM.readLine();
              for (index = 0; index = room_nbr.length; index++)
                   System.out.print(room_nbr[index] + "\t\t" + test_score[index]);
         public static void startUp()
         System.out.print("Einstein Elementary Test Scores\n\n");
         System.out.print("Room Number\t\tTest Score Average\n\n");
    }          // end of class declaration

    thank you. here's the code.
    import java.io.*;       // needed for stream readers
    import java.lang.*;   
    public class testScores extends Object
         public static void main(String args[] ) throws Exception
         // declare variables for input
            String      records;
            String      room_nbr_input;
            String      test_score_input;
            String      student_id;
            int             room_nbr_nbr;
            int             test_score_nbr;
            int          index;
            String[] record = new String[3];
            int[]      room_nbr = new int[30];
            int[]       test_score = new int[30];
            int[]      kount = new int[30];
              // created file reader and buffered reader
              FileReader frM;
              BufferedReader brM;
              // open file
              frM = new FileReader("einstein_testscores_2009.txt");
              brM = new BufferedReader(frM);
         // print headings
              startUp();
              // get one record from file
              records = brM.readLine();
              while(records !=null)
              //split the record into three fields = the array record[], then assign those values to variables
              record = records.split(", ");
              student_id = record[0];
              room_nbr_input = record[1];
              test_score_input = record[2];
              //change the data into integers
              room_nbr_nbr = Integer.parseInt(room_nbr_input);
              test_score_nbr = Integer.parseInt(test_score_input);
              //put the variables into arrays
              room_nbr[room_nbr_nbr -1] = room_nbr_nbr;
              test_score[room_nbr_nbr -1] = test_score[room_nbr_nbr -1] + test_score_nbr;
              //get new record
              records = brM.readLine();
               for (index = 0; index = room_nbr.length; index++)
                    System.out.print(room_nbr[index] + "\t\t" + test_score[index]);
         public static void startUp()
         System.out.print("Einstein Elementary Test Scores\n\n");
         System.out.print("Room Number\t\tTest Score Average\n\n");
    }          // end of class declaration

  • Compatible & Incompatible types

    Why is that I can assign a integer value to a double variable, but cannot assign a double value to an integer variable? Aren't double and integer compatible types? Isn't there a concept of truncation in java? I searched the net but in vain. I couldn't find the exact answer I was looking for. So I am posting in this forum.
    PS: I understand it is not possible to assign an integer to a string since they are incompatible types.
    Edited by: 964980 on Mar 26, 2013 9:29 PM

    Why is that I can assign a integer value to a double variableBecause it's a widening conversion that doesn't lose any information. See JLS #5.1.2.
    but cannot assign a double value to an integer variable?Because it's a narrowing conversion that might lose information. You can do it as long as you write an explicit typecast. See JLS #5.1.3.
    Aren't double and integer compatible types?No, see above.
    Isn't there a concept of truncation in java?Yes, see above.
    @rp0428 I don't see what good asking for the code and the error message does, in a fundamental case like this. It doesn't change the answer, and your own answer (is/isn't) wasn't too inspiring.

  • Compiler error: incompatible types

    When I try to compile this code it gives the error "incompatible types".
    import java.util.ArrayList;
    public class Poly {
         public static void main (String args[]) {
              Number integer = new Integer(1);
              ArrayList<Number> integers = new ArrayList<Integer>();
    }Assigning a Number object an Integer which extends Number works fine.
    But when I try to assign an ArrayList<Number> object an ArrayList<Integer> object it gives an imcompatible types error.
    Shouldn't it work?
    Edited by: aexyl93 on Jun 7, 2010 2:00 AM
    Edited by: aexyl93 on Jun 7, 2010 2:05 AM

    aexyl93 wrote:
    Thanks for the quick replies.
    I've never seen ArrayList<? extends obj> before.Nitpick: it's not "? extends obj" it's "? extends SomeClass".
    "obj" kind of implies that you could use a variable/field here, which is wrong.
    I thought it would be able to hold an object which extends what it's supposed to hold.A List<? extends Number> could contain any class that extends Number (as well as Number itself if it weren't an abstract class). However you can't add anything (except null), because you don't know the concrete type at this point.

  • Help on Incompatible types

    Sample 1:
    public interface I<T extends I<?>>
      I<? extends I<T>> m1 ();
    public class Z<T extends I<?>> implements I<T>
      public I<? extends I<T>> m1 ()
        return m2();
      protected I<? extends I<T>> m2 ()
        return null;
    javac Z.javacompiled with no problems
    Sample 2:
    public interface I<Tx, T extends I<Tx, ?>>
      I<Tx, ? extends I<Tx, T>> m1 ();
    public class Z<Tx, T extends I<Tx, ?>> implements I<Tx, T>
      public I<Tx, ? extends I<Tx, T>> m1 ()
        return m2();
      protected I<Tx, ? extends I<Tx, T>> m2 ()
        return null;
    javac Z.javaZ.java:5: incompatible types
    found : I<Tx,capture of ? extends I<Tx,T>>
    required: I<Tx,? extends I<Tx,T>>
    return m2();
    ^
    1 error
    Well... can anyone help with this? Or at least some explanations why adding second generic generates this problem?

    The problem is in the recursion, not in the second type argument. If you changed your first interface from
        public interface I<T extends I<?>> {} to
        public interface I<T extends I<T>> {} you would run into the same error message. For sake of clarity let's discuss the issue using your first example in a slightly simplified form:
        public interface I<T extends I<T>> {}
        public class Z<E>
          public I<? extends I<E>> m1 ()
            return m2();
            /* error: incompatible types
               found   : I<capture of ? extends I<E>>
               required: I<? extends I<E>>
               return m2();
                        ^
          protected I<? extends I<E>> m2 ()
          { return null; }
        }The error message is not awfully helpful, because the "E" is different in both types.
    Method m2 returns a reference of type I<capture of ? extends I<E>>, where E extends I<capture of ? extends I<E>>, that is, it returns a concrete instantiation of the interface, namely I<SomeType> with a type that extends I<SomeType> with a type that extends ... continued recursively.
    On the other hand, method m1 is supposed to return a reference of type I<? extends I<E>>, where E extends I<? extends I<E>>, that is, it returns a wildcard instantiation of the interface, namely I<? extends I<SomeType>> with a type that extends I<? extends I<SomeType>> with a type that extends ... continued recursively.
    And here is the point: The first construct leads to a concrete instantiation like a List<List<List<String>>>. The second construct lead to a recursive wildcard instantiation like List<? extends List<? extends List<?>>>. As soon as the wildcard appears on a nested level, the types are no longer compatible.
    It's like assigning a List<List<String>> to a List<List<?>>. It's not permitted because the first is a list of string-lists and the second is a list of mixed-lists. You cannot assign one to the other.
    In your example, changing
        public interface I2<Tx, T extends I2<Tx, ?>> to
        public interface I2<Tx, T extends I2<?, ?>>might do the trick.
    (As usual, ignore the annoying additional angle brackets.)

  • Incompatible type on stack

    does anybody have any idea why i am getting an "incompatible type on stack error" when i try to create my stubs?
    thanks!
    peter

    Hi. This is a more precise followup to my posting. I have never
    experienced a VerifyError before, here is the error that i got
    when running rmic on my class file.
    Exception in thread "main", java.lang.VerifyError: verification
    failed at PC 55 in sum.rmi.runtime.log: <clinit>(V()): incompatible
    type on stack.
    I have run a jfc-dump and it seems to have something to do with the
    vector array i have assigned to the RMI clients but i am not to sure
    how to fix it. any suggestions would be appreciated.
    regards,
    peter

  • Incompatible types required boolean found string

    I am trying to set a value for a variable called Location when ever the value for the location is "AFRICA"
    I need to reset it to be "55555".
    What I am getting is that 'Incompatible types required boolean found string' under the if statemant. Can anyone shade some light on this?
    String Location = filename.substring(12,17);
    String AP = "AFRICA";
    System.out.println(Location);
    if (Location = AP)
    System.out.println(Location);
    Location = "55555";
    thanks

    rp0428 wrote:
    The IF condition needs to be a BOOLEAN. The '=' is used to do an assignment. The boolean would be '=='.
    But to compare strings why aren't you using
    if (Location.equalsIgnoreCase(AP) {
    To stress this a little more:
    <tt>==</tt> applied between References will compare the Adresses they point to. This means this will only be true if both References point to the identical Object. @Test
    testStringEquality(){
       String s1 = "my Test"
       String s2 = "Test"
      Assert.assertTrue("This strings are equal",s1.equals("my "+s2));
      Assert.assertFalse("This strings are not identical",s1 == ("my "+s2));
    }So use <tt>==</tt> only for primitive number types (those starting with a lower case letter).
    bye
    TPD

  • Incompatible types with generics problem

    Hi,
    I get a mysterious compiler error:
    C:\Documents and Settings\Eigenaar\Mijn documenten\NetBeansProjects\Tests\src\tests\genericstest.java:26: incompatible types
    found : tests.Store<T>
    required: tests.Store<T>
    return store;
    1 error
    BUILD FAILED (total time: 0 seconds)
    in the following code:
    class Supply<T extends Supply<T>>{}
    class Store<T extends Supply<T>>{ }
    class A<T extends Supply<T>>{
        private Store<T> store;
        class B<T extends Supply<T>> {
            public Store<T> getStore(){
                return store;                         <-- compiler error!
    }Any help would be greatly appreciated.
    Edited by: farcat on Jan 13, 2009 1:23 PM

    Note that the type parameter T used to define class B is not the T used to define class A. What you wrote can be more clearly written:
    class Supply<T extends Supply<T>>{}
    class Store<T extends Supply<T>>{ }
    class A<T extends Supply<T>>{
        private Store<T> store;
        class B<U extends Supply<U>> {
            public Store<U> getStore(){
                return store;
    }Which produces the more readable error message:
    A.java:10: incompatible types
    found   : Store<T>
    required: Store<U>
                return store;B, being a nested, non-static class is already parameterized by T:
    class Supply<T extends Supply<T>>{}
    class Store<T extends Supply<T>>{ }
    class A<T extends Supply<T>>{
        private Store<T> store;
        class B {
            public Store<T> getStore(){
                return store;
    }

  • No POWL object types are assigned to you. Please inform your system admin

    Hi experts,
    We are on SRM 7.0 and ECC 6.0.
    We are using netweaver 7.0 (SP7) for our portal instance. SSO, UWL etc have been configured in the Portal.
    Now when the user logs in to create a shopping cart and clicks on the Employee Self Service link, he gets the following error:
    "No POWL object types are assigned to you. Please inform your system adminstrator"
    What could be the resolution for this?
    Regards

    Hi Jay,
    Thanks for the update.
    There were 2 roles for employee in portal. I changed the role. The one with details pcd:portal_content/com.sap.pct/specialist/com.sap.pct.srm.srm70/com.sap.pct.srm.core.fl_core/com.sap.pct.srm.core.fl_roles/com.sap.pct.srm.core.ro_employeeselfservice worked.
    I did not have to maintain the settings for 'Defining query visibilty at role level'.
    However now once the shopping cart has been ordered, I come back to check it's status under the ESS link, I see that it is awaiting approval, but when I try to open the SC, it does not open.
    Also I am unable to open the SC if I search it under 'Advanced Search'.
    Any inputs on what could be the reason?
    Regards

  • Incompatible types in case statement

    I'm getting incompatible types inside this case statement :
    inString = s_in.readUTF();
                switch (inString.substring(1,3))
                    case nam:
                        ChatClient.nameArea.append(inString);
                        break;
                    case txt:
                        ChatClient.chatArea.append( "\n >>>" + inString );
                        break;
                }If you want, or need to see more or all of the code in this class, just ask.

    This is because you can't use Strings within a switch statement. Use if statements instead.

Maybe you are looking for