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 3442516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:40:42+00:00 2026-05-18T08:40:42+00:00

Is it possible to instantiate a NSValue with a pointer to a C structure

  • 0

Is it possible to instantiate a NSValue with a pointer to a C structure without having to create a autorelease pool? For the moment, I do this:

NSValue* val = [NSValue valueWithPointer:(const void*)structure];

but this is release by the autorelease pool. I would like to take control of this and be able to dealloc it when I want. Is this possible? I tried this:

NSValue* value = [[NSValue alloc] initWithBytes:(const void*)structure objCType:@encode(const void*)];
[value release];

but it is crashing for some reason. Any other way to be able to release immediately?
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-05-18T08:40:43+00:00Added an answer on May 18, 2026 at 8:40 am

    You’re supposed to be passing a pointer to the type that’s given for the objCType: argument. You’re passing a variable of the type. So, for example, if you have a variable int foo that you want to store in an NSValue, you’d write [[NSValue alloc] initWithBytes:&foo objCType:@encode(int)]. So if you want to store a pointer, you need to pass a pointer to that pointer as the bytes. Passing the pointer itself will cause NSValue to try to follow the pointer and then treat the bytes that it’s pointing to as a pointer as well.

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

Sidebar

Related Questions

Possible Duplicate: Instantiate a class with or without parentheses? This is a minor quibble,
Is this possible? What I want to do is have my doWork method instantiate
Is it possible to instantiate a pointer using (unsafe) C# at any given memory
Possible Duplicate: Size of folder or file I used this code to instantiate a
Is it possible to instantiate a class in a separate thread without a compile
Is it possible to send extra parameters when I instantiate this button class, like
Is it possible to create a new app domain and instantiate an instance of
Is it possible to instantiate a class from a string, without declaring another variable
How do I instantiate the asp.net System.Web.UI.Page object in MVC3? Is this even possible?
Possible Duplicate: Best method for storing this pointer for use in WndProc I'm trying

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.