Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8383603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:12:11+00:00 2026-06-09T17:12:11+00:00

Here is the problem: I am passing a pointer to an object to performSelector:withObject

  • 0

Here is the problem:
I am passing a pointer to an object to performSelector:withObject via [NSValue valueWithPointer:] for example like this:

// GVertex is NSObject subclass
GVertex *vertex = [[GVertex alloc] initWithX:5.0f andY:4.5f]];
GVertex **vertexPtr = &vertex;
// later in code when I need to process the vertex
[self performSelector:@selector(processVertex:) withObject:[NSValue valueWithPointer:vertexPtr]];

then in my processVertex:(NSValue *)vertexValue method I want to get the passed vertex and I do it like this:

- (void)parseVertex:(NSValue *)vertexValue
{
    GVertex *vertex = (GVertex *)[vertexValue pointerValue];
    ...
    [vertex setFlags:32]; <<-- This gives me EXC_BAD_ACCESS
    ... 
}

I have tried many combinations of (*) and (&) everywhere but can’t get it to work.
What am I doing wrong ? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:12:13+00:00Added an answer on June 9, 2026 at 5:12 pm

    The pointer you’re putting into the NSValue is a pointer to a pointer (or the address of a pointer), but you’re retrieving it as if it’s a plain object pointer. Moreover, the pointer whose address you’re taking is a local variable — that address is going to be garbage in the context of a new method.

    This should work if you just store the (single) pointer in the NSValue:

    [self performSelector:@selector(processVertex:) withObject:[NSValue valueWithPointer:vertex]];
    

    Beware of memory management issues, however — NSValue does not copy or take ownership of the memory at that pointer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
Im having a problem here. i downloaded jake wharton. He gave an example of
I have a problem here. My Zend_Forms do not render in view script. Via
Here is a minimal example which illustrates my problem test.c: #include <stdio.h> #include <pthread.h>
I encountered a problem with passing Image object (captured with Point Grej FlyCapture2 SDK)
So my problem is this...when I am trying to allocate memory to a pointer,
I have one problem with parsing *.docx document with OpenXML (C#). So, here's my
The problem here is how to add an NSPopUpButton in Xcode 4's Interface Builder
date here my problem: String datetime = 2012-03-24 23:20:51; I know that that string
Super weird problem here. I'm having trouble getting jQuery to bind any selectors except

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.