Get a reference to an object from a touch

I have no idea how to get the reference to an UIImageView object from a touch gesture. So far all I know how to do is get a reference to the touch. This is the code I have so far:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
printf("TOUCH ");
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.view];
Any help would be greatly appreciated

There may be more elegant methods, but what I did was to find out which sub views bounds covered the coordinates of the selected point. My task was easy since I had a sudoku grid, so converting coordinates into the index into an array of view instances was easy.
- (unsigned int) setSelectedIndexForXCoordinate:(float) x YCoordinate:(float) y
int column = (int) ( ( 9.0 * x ) / 320.0 );
int row = (int) ( ( 9.0 * y ) / 320.0 );
unsigned int index = ( ( row * 9 ) + column );
[self setSelectedIndex:index];
return index;

Similar Messages

  • Do I have to use lookup() to get a reference of remote object?

    Hello,
    I appreciate the help from you guys in advance. My question is, do I have to use lookup() to get the reference to a remote object? Right now I want to pass the remote object itself which can be serialized via stream. I am not sure if this way works.
    Cheers!
    Steve

    some part code:
    client:
    lookup=UC_LookUp.StkTakeListingHdrLookup().getStkTake(usrInfo,tfStkTakeListNo.getText());
    UC_LookUp
    public static basewms.uc.interfaces.UC_ISCSStkTakeListingHdr_Remote StkTakeListingHdrLookup()
          if (look_up==null) look_up= new UC_LookUp();
          if(stktakelistinghdr == null)
          stktakelistinghdr = look_up.startLookUp("UCStkTakeListingHdr","192.168.10.98", 7000);
          while (stktakelistinghdr==null)
               try { Thread.sleep(1000); }catch(InterruptedException e) {}
          return (basewms.uc.interfaces.UC_ISCSStkTakeListingHdr_Remote)look_up.getRemote(stktakelistinghdr);

  • Client unable to get the javax.activation.DataHandler object from Server

    Hi All,
    I am trying to download the file from the server to the client using Javax.Activation.Data Handler object with IBM web services. But server always returning the Data Handler object is null. I am wondering why it is behaving like this.
    My requirement is add the file to the Data Handler object from the server and read the same from the client. But I am always getting Data Handler object is  null at the client place.
    Please see the client side code and server side code below.
    Server side Code:
    This is the simple web service method, its creating the Data Handler object and adding it to the Hash Map and returning the Hash Map object to the client.
    public Hashtable download()
              DataHandler dh = null;
              HashMap hashMap =new HashMap();
              try{
                   //Sample test files contains data
                   String downLoadFName="C:/ADP/downLoadData.txt";
                   //Creating the DataHandler Object with sample file
                   dh      =      new DataHandler(new FileDataSource(new File(downLoadFName)));
                   //Keeping the DataHandler object in the HashMap.
                   hashMap.put("DATAHANDLER",dh);
                   //keeping the sample test message object in the HashMap
                   hashMap.put("TEST","Keeping the DataHandler and test messages in the hashTable");                         
              }catch(Exception e){
                   logger.error("Error :while sending the data:"+e.getMessage(), e);
              //retrun the HashMap object to the client.
              return hashMap;
    Client Side Code:
    This is the simple client code, and connecting to the server and invoking the web service method
    //This is the client code,Just invoking the webservice method from the Webspehre server.
    public class WebserviceClient {
         static DocumentTransfer controller     =     null;
         public static void main(String args[]){     
                DocumentTransferService service          =     null;
              try{
                   //Creating the service Object
                   service               =     new DocumentTransferServiceLocator();
                   //Getting the Server connection
                    controller          =      (DocumentTransfer)service.getDocumentTransfer(new java.net.URL("http://localhost:9081/eNetsRuntimeEngine/services/DocumentTransfer"));
                    //Calling the download method from the server and it returns HashMap object.
                   HashMap hashMap     = controller.download();
                   //Getting the DataHandler Object from the HashMap
                    DataHandler dh=(DataHandler)hashMap.get("DATAHANDLER");
                   System.out.println("DATAHANDLER: :"+dh);
                   //Getting the String object from the HashMap.
                   String message=(String)hashMap.get("TEST");
                   System.out.println(": :"+message);
               }catch(Exception e){
                    System.out.println("Exception :Not able to get the file :"+e.getMessage());
    Could you please give me some inputs on this?
    Thanks in advance,
    Sreeni.

    Hi Stif,
    Thanks for your response.I did debug from server side,it has printing content of Data Handler properly.
    Also i have debug request and response messages using TCP/IP monitor(RAD environment has this feature).The response from the server is going proplery.
    But the client side Data Handler is coming null.
    Any advice or solution would be greatly appreciated.
    Thanks,
    Sreeni.

  • Can I get the reference to all objects in JVM Heap?

    Hello,
    Thanx in advance for reading (and replying) to this problem.
    I need to find an object whose reference I dont have.
    I feel the best place to search for is the JVM heap.
    If I get that JVM heap, and am able to get all the objects created, I can locate the particular object that I am looking for.
    Is there a way to od this????
    Any suggestions ????
    Vikas

    JVMTI will mostly help you in this case. But i recomend you to review you application design, because such services are unsafe and rather tricky.

  • How to get the reference of one object's parent

    hello guys
    i have classA and classB like bellow
    class ClassA{
    public var myVar:String="test";
    public function ClassA()
    new ClassB();
    class ClassB{
    public function ClassB()
    trace("my parent is"+XXX);
    trace("my parent var is"+ XXX["myVar"]);
    suppose XXX in classB is the reference of instance of ClassA.how do i get it?

    Parent/child relationships pertain to display list only. When you instantiate ClassB in ClassA - it becomes a property of the scope where you instantiated it - NOT A CHILD. Note the word "scope" - variable may belong to class or function, etc.
    Instance of a class is totally agnostic to who instantiated it unless you pass a reference of the class that made the instance. Nevertheless, of a class is a DisplayObject, once it is placed on display list - it knows who the parent is.
    Instance can be either property or child or both proeprty and child.

  • Getting hold of browsers document object, from an applet

    Well, at least that's how i think the problem will be solved.
    The purpose is to insert some text into a hidden field on a form in the html where the applet is embedded.
    so that this can be submitted along with the rest of the information that is entered through that page.
    i've been looking at the AppletContext but i don't think this will provide what's necessary.
    an alternate way of solving this would be to make an http-post with the information, since i prefer using our webserver to perform this.if this is the only way, is there a http-post object i can use for this, from an applet?

    One way is to move the entire form into your applet so that it can do a post and send all the data itself (or vice-versa; avoid using the applet).
    Another option might be to do it in two steps, have your form on one page then post all the details to the next page which contains the applet.
    The only other option I can think of is to use JSObject to call a javascript function. Look at this link http://java.sun.com/products/plugin/1.2/docs/jsobject.html
    Rob.

  • Getting a sequence of Point2D objects from a PathIterator?

    I would like to be able to take an arc or some other non-straight shape and convert it's geometry into a series of points that (roughly) traverse it. I attempted the following, as an example to see how it would work:
         arc = new Arc2D.Double(50,50,150,150,135,-270,Arc2D.OPEN);
         PathIterator pi = arc.getPathIterator(null);
         double[] coords = new double[6];
         int code;
         while (!pi.isDone()) {
              code = pi.currentSegment(coords);
              switch (code) {
              case PathIterator.SEG_CLOSE:
                   System.out.print("Close: ");
                   break;
              case PathIterator.SEG_CUBICTO:
                   System.out.print("Cubic To: ");
                   break;
              case PathIterator.SEG_LINETO:
                   System.out.print("Line To: ");
                   break;
              case PathIterator.SEG_MOVETO:
                   System.out.print("Move To: ");
                   break;
              case PathIterator.SEG_QUADTO:
                   System.out.print("Quad To: ");
                   break;
              default:
                   break;
              System.out.println(coords[0] + "," + coords[1] + "   " + coords[2] + "," + coords[3] + "   " + coords[4] + "," + coords[5]);
              pi.next();
         }The output was this:
    Move To: 71.96699141100893,71.96699141100893   0.0,0.0   0.0,0.0
    Cubic To: 101.25631329235418,42.6776695296637   148.74368670764582,42.6776695296637   178.03300858899107,71.96699141100893
    Cubic To: 207.32233047033628,101.25631329235418   207.32233047033628,148.74368670764582   178.03300858899107,178.03300858899107
    Cubic To: 148.74368670764582,207.32233047033628   101.25631329235418,207.32233047033628   71.96699141100893,178.03300858899107Clearly this isn't what I'm looking for. Does anyone have any suggestions on how I might go about doing this?
    Any input is appreciated.

    import java.awt.*;
    import java.awt.geom.*;
    import java.util.List;
    import java.util.*;
    import javax.swing.*;
    public class TraversePoints extends JPanel {
        Arc2D.Double arc = new Arc2D.Double(50,50,150,150,135,-270,Arc2D.OPEN);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(Color.blue);
            g2.draw(arc);
            g2.setPaint(Color.red);
            AffineTransform at = AffineTransform.getTranslateInstance(150, 100);
            Point2D.Double[] points = getTraversalPoints(at, 1.0);
            for(int j = 0; j < points.length; j++)
                g2.fill(new Ellipse2D.Double(points[j].x-2, points[j].y-2, 4, 4));
        private Point2D.Double[] getTraversalPoints(AffineTransform at,
                                                    double flatness) {
            List<Point2D.Double> list = new ArrayList<Point2D.Double>();
            PathIterator pit = arc.getPathIterator(at, flatness);
            double[] coords = new double[6];
            int count = 0;
            while(!pit.isDone()) {
                int type = pit.currentSegment(coords);
                switch(type) {
                    case PathIterator.SEG_MOVETO:
                        // fall through
                    case PathIterator.SEG_LINETO:
                        list.add(new Point2D.Double(coords[0], coords[1]));
                        break;
                    case PathIterator.SEG_CLOSE:
                        System.out.println("CLOSE");
                        break;
                    default:
                        System.out.println("unexpected type = : " + type);
                count++;
                pit.next();
            System.out.printf("%d points at flatness = %.1f%n",
                               count, flatness);
            return list.toArray(new Point2D.Double[list.size()]);
        public static void main(String[] args) {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(new TraversePoints());
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • How can I get my non purchased song content from ipod touch 4 back to my itunes library. My library

    How can I get my non purchased song content back into my itunes library from my ipod touch 4. My itunes had disappeared so I had to get another itunes & start again. I still have the original song content in the ipod.

    There is 3rd party software out there, but not supported by Apple, see this thread:http://discussions.apple.com/thread.jspa?threadID=2013615&tstart=0

  • Getting Sequence object from pre-step substep of Sequence Call based step type

    How to obtain reference to Sequence object from within pre-step substep of Sequence Call based custom step type?
    Given: new custom step type which based on NI Sequence Call step type. There is Pre-Step substep exist for this step type.
    How to get reference to Sequence object representing Sequence which will run?
    Although there is possible to examine SequenceAdapter and SequenceCallModule properties, it seems redundant since module (Sequence) is already loaded by TestStand ("NI TestStand Reference Manual. Table 3-4. Order of Actions that a Step Performs"   Action #6, while my code is running as Action #13).
    Thanks.
    Misha

    Could you explain what you want to do ?
    Why do you want to get the sequence object within a pre-step substep ?
    I give you some informations but I don't know if it's the better way to do what you want (because I don't know what you want to do with the sequence object).
    If the substep uses the ActiveX adapter :
    You can get the sequence object but you should save the object reference in a StationGlobals variable.
    And you should release the object reference within your sequence when you don't need it any more.
    If the substep uses another module adapter: 
    Get the step module, then the sequence name (module property).
    Then get the sequence object by the sequence name from the sequence file.
    Here are the paths to use for both methods :
    Sequence Name property path : Step.Module.SeqName
    Sequence Object path : RunState.SequenceFile.GetSequenceByName (seqname)

  • Record Management: get logical document object from physical doc. object

    Hello,
    I'd like to get logical document from physical document (sdok object - stricture containing class and objid).
    There is BAPI for "opposite direction": SDOK_LOIO_PHYSICAL_OBJECT_GET. By this FM I can get physical document's sdok object from logical document's sdok object.
    Can anybody tell me BAPI's name for it?
    I tried SDOK_PHIO_LOGICAL_OBJECT_GET, but this BAPI doesn't exist.
    Best regards,
    Josef Motl

    Josef,
    There are I don't believe there are any bapi's for this. You probably have to do this via ABAP OO. Create an object of the type CL_SRM_DOCUMENT. This is your logical (LOIO) object of your document. You have to enter the documentclass and the objectid of the document. This class has a method get_variant. This variant is your fysical (PHIO) object of the document. Use version and variant 0 so you will get the latest version object of your document.
    If this isn't the answer, can you please explain where do you get the fysical object from if you haven't got the logical first?
    Regards,
    Tjalling-Jan

  • How to get a reference to the owner of a class instance?

    Within a method of a class, how can I get a reference to the
    object containing the class instance?
    To be clear: I have class B that contains a method, say
    "myfunc()". Class A (say, the application itself or a custom
    component) instantiates a new instance of Class B : myclassB=new
    ClassB()
    Now, from within myfunc() can I get a reference to Class A?
    The simplest way here is to pass a "this" reference when
    calling myfunc(), i.e. "myclassB.myfunc(this)" but I would prefer
    not to have to remember to always use 'this'.

    Are these objects within each other. Does classA own classB?
    If that is the case, then Greg is correct and it should be
    available in parentDocument.
    In projects in the past we have created a central
    refObjectLocator object that is available to all objects.
    Mostly we use events to communicate between objects. Dispatch
    an event and let whoever listen for it.
    Here is a copy of our reflocator if you are interested.
    package com.goconfigure.model {
    import mx.collections.ArrayCollection;
    import com.adobe.cairngorm.model.ModelLocator;
    import com.goconfigure.util.HashMap;
    [Bindable]
    public class RefObjectLocator implements ModelLocator {
    // this instance stores a static reference to itself
    private static var refObject : RefObjectLocator;
    public var refObjectHM : HashMap = new HashMap();
    // singleton: constructor only allows one model locator
    public function AppLocator() : void {
    if ( RefObjectLocator.refObject != null )
    throw new Error( "Only one RefObjectLocator instance should
    be instantiated" );
    // singleton: always returns the one existing static
    instance to itself
    public static function getInstance() : RefObjectLocator {
    if ( refObject == null )
    refObject = new RefObjectLocator();
    return refObject;
    public function addRefObject( pRefObject : Object, pName :
    String ) : void {
    refObjectHM.put(pName,pRefObject);
    public function getRefObject( pName : String ) : Object {
    return refObjectHM.getValue(pName);
    public function removeRefObject( pName : String ) : void {
    refObjectHM.remove(pName);
    public function clearRefObject() : void {
    refObjectHM.clear();

  • Pass an object from a static method

    Hi,
    I'm trying to pass a reference to an object from a static method, but I get an error when compiling.
    Say for example I have this:
    public class obj1 {
    public void myMethod (int i, Object ob, etc...) {
    ...and I want to call this method from a method that looks like this:
    public class obj2 {
    public static int anotherMethod(...) {
    obj1.myMethod(1,this,...);
    ...Can I pass a reference from obj2 to obj1 any other way?
    Thanks alot.

    how can I get a reference to obj2 then?Pay no attention to zdude's answer - it's nonsense.
    You're confused about basic Java concepts. obj2 is a class, not an object. References point to objects, not classes. There is no obj2 object in the code you show, so you cannot have a reference to an obj2 object.
    Maybe if you post some more code, we can get an idea of what you're trying to do. You might want to try the New to Java forum.

  • Reference to C# objects in TestStand - how to save and retreive them

    I am new to LabView and TestStand.
    I want to use 2 .NET objects in those applications
    In Labiew, I successfully created the objects, manipulate the functions through VIs and closed the references.
    While I could use the VIs for TestStand, I would rather use the DLL directly.
    I am able to create both objects in a sequence, but I have problems with the following:
      - I don't know how to save the reference to the object after the constructor is run.
        - is the object stored in Globlal variables? I tried 'RunState.Engine' but it does not work
      - I don't know how to get the reference back in the other steps where I want to reuse the object to invoke a method on.
      - Once I can do the above, I need to get it to work in the 'batch' or 'parallel' modes.
         I am using successfully the 'RunState.TestSockets.MyIndex' to select my testing resources,
         but I am still confuse as where the array of objects would be.
         Note that I already set the number of DUT <> 1 and I can create successfully my 2 objects in X instances.
    Thanks,
    Daniel Coupal

    dcoupal,
    Getting the reference to the object involves specifying that as a return value in one of your parameters when you specify the module for that action. Inside of the parameters table you can also save that return value as a local object reference and then use it later on in the sequence.
    Regarding your second question, I'm not sure what the array of objects is that you're referring to but this KB might be of some assistance.
    Message Edited by Jon M on 11-01-2006 12:44 PM
    Test Engineer - CTA

  • How to execute Custom java data source LOV view object from a common mthd?

    Hi,
    My application contains Custom java data source implemented LOVs. I want to have a util method which gets the view accessor name, find the view accessor and execute it. But i couldn't find any API to get the view accessors by passing the name.
    Can anyone help me iin how best view accessors can be accessed in common but no by creating ViewRowImpl class (By every developer) and by accessing the RowSet getters?
    Thanks in advance.

    I am sorrry, let me tell my requirement clearly.
    My application is not data base driven. Data transaction happens using tuxedo server.
    We have entity driven VOs as well as programmatic VOs. Both are custom java data source implemented. Entity driven VOs will participate in transactions whereas programmatic VOs are used as List view object to show List of values.
    Custom java datasource implementation in BaseService Viewobject Impl class looks like
            private boolean callService = false;
        private List serviceCallInputParams = null;
        public BaseServiceViewObjectImpl()
            super();
         * Overridden for custom java data source support.
        protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams)
            List dataFromService = null;
            if(callService)
                callService = retrieveDataFromService(serviceCallInputParams);
            setUserDataForCollection(qc, dataFromService != null? dataFromService.iterator(): null);   
            super.executeQueryForCollection(qc, params, noUserParams);
         * Overridden for custom java data source support.
        protected boolean hasNextForCollection(Object qc)
            Iterator<BaseDatum> datumItr = (Iterator<BaseDatum>) getUserDataForCollection(qc);
            if (datumItr != null && datumItr.hasNext())
                return true;
            callService = false;
            serviceCallInputParams = null;
            setFetchCompleteForCollection(qc, true);
            return false;
        }Individual screen developer, who want to load data to VO, will do something like the below code in their VO impl class
        public void fetch()
            BaseServiceViewObjectImpl vo = this;
            vo.setCallService(true);
            vo.setServiceCallInputParams(new ArrayList());
            vo.executeQuery();
        }As these custom java data source implemented LOV VOs comes across the screens, i want to have a util method at Base VOImpl class, that gets the view accessor name, finds the LOV VO instance, retrieves data for that. I want to do something like
         * Wrapper method available at Base Service ViewObject impl class
        public void fetchLOVData(String viewAccessorName, List serviewInputParams)
            // find the LOV View object instance
            BaseServiceViewObjectImpl lovViewObject  = (BaseServiceViewObjectImpl) findViewAccessor(viewAccessorName);
            // Get data for LOV view object from service
            lovViewObject.setCallService(true);
            lovViewObject.setServiceCallInputParams(serviewInputParams);
            lovViewObject.executeQuery();
    Question:
    1. Is it achievable?
    1. Is there any API available at View Object Impl class level, that gets the view accessor name and returns the exact LOV view object instance? If not, how can i achieve it?

  • Only edit objects from package ZPACKAGE in local requests

    Hi Experts,
    I was adding a secondary index to a Ztable present in a package ZPACKAGE. When I tried to save in a workbench request, I got the error message "You cannot use request XXXXXX". I then created a local change request where the target system is not mentioned in the transport request. I was able to save the index and later I mentioned the target system. When I tried to release the transport request, I get the message "Only edit objects from package ZPACKAGE in local requests". Kindly suggest what can I do save the changes in a transport request and release it.
    Thanks

    Check out the transport layer and target system for that transport layer. As someone suggested, talk to your basis.
    This is most common when you have the actual table in temp folder but the index stored in Zpackage.
    I would first check my objects package to make sure that they are in right package. If everything @ right place, then i will check the package transport layer and software component then check the 'use access' of the package. if the package is good then check the transport path and target systems for each transport later.

Maybe you are looking for

  • Can I create a custom-scripted dynamic stamp in Acrobat Standard or do I have to buy Acrobat Pro?

    I am researching options for the company I work for to take it's invoicing system paperless and I need to know if I can create a custom-scripted dynamic stamp in Acrobat Standard or is that possible only in Acrobat Pro?

  • Java_home issue on Tomcat 4.1.X

    I have a problem running Tomcat as a service in XP. Before, I could not get the index.jsp to load that comes with Tomcat. I disabled it as a service and added JAVA_HOME to the startup and shutdown bat files. Starting it from startup.bat, everything w

  • How can include '*' option in a query

    Hi, I have an input field for Material number , and this is used in a join to fetch data , my problem is some times user will enter material number as 456* , in this case how can i change the query. Please see the join,   select dmatnr as material dw

  • I'm getting a ServletException and cannot login on iPortal anymore. What's going on ?

    Hi! Yesterday my iPortal installation was working fine, but today it just crashed. The gateway doesn't start and all logins say I must have a portal profile. Including the portal admin. I've checked the profile with and LDAP Browser and "Authenticati

  • Contact Sheet II.

    No matter what I do, the file extension names (i.e. jpg) show up in the contact sheet. Any way to eliminate them? I'm creating a grid for a gallery show and having the filename extensions added to the title of each image is cheesy.