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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:10:56+00:00 2026-05-26T21:10:56+00:00

How can I store/retrieve a CGFloat as a property of a subclassed UIImageView ?

  • 0

How can I store/retrieve a CGFloat as a property of a subclassed UIImageView? I can set it’s value but when I retrieve it, it is corrupt. NSString properties work fine.

.h

@property CGFloat myFloat;

.m

[sender setMyFloat:someFloat];
[sender myFloat];  //<- corrupt? 

********* UPDATE ***********

I wanted to thank you for all of your suggestions, they were all correct. My problem was more complex than I thought. The sender is a UIPanGestureRecognizer attached to the UIImageview I was having problems with. The UIPanGestureRecognizer calls the selector move:(id)sender and this is where my problem is.

Within move: I could successfully perform:

[[sender view] setMyString:@"test"];

and retrieve it back with

[[sender view] myString];

I could not however set or retrieve any float property at all without including (id)self. For example:

[[sender view] setMyString:@"test"]; //->works

[[sender view] setMyFloat:1.0f]; //->does not work

But this works:

[[[sender view]self] setMyFloat:1.0f]; //->works

This is the strange part which led me to believe I was having a casting problem with my float! I have a several NSString properties and they return just fine but the CGFloats would not. Could someone explain to me why somehow I achieve success with strings but the float gets lost here?

  • 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-26T21:10:57+00:00Added an answer on May 26, 2026 at 9:10 pm

    ANSWER #2: NSLog syntax?

    How are you validating the value after it is set? If you are using NSLog make sure you have the right format code for a float (e.g. NSLog(@"new float value = %f", myFloat).

    ORIGINAL ANSWER: wrong setter (was typo in question)

    You are calling the wrong setter method. The correct setter is:

    `[sender setMyFloat:someFloat]`
    

    EDIT: OP has updated his question to remove the typo

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

Sidebar

Related Questions

How can I set some text to a label but also store its ID.
How can I store a value within Selenium-RC (through PHPUnit) and then retrieve/access it
How can I store and retrieve the number 2**10000 in a binary file in
How can I retrieve the return value of a stored procedure using iBatis.NET? The
My MySQL database can store the euro symbol just fine (as I have tested
how can I store and retrieve in SQLite database multiple values for the same
How can I store and retrieve preferences in Android?
I have a list of key/value pairs I'd like to store in and retrieve
Core Data is working pretty smoothly in my app. I can store and retrieve
In Windows phone we can store and retrieve anything using IsolatedStorageSettings.ApplicationSettings.Add(foo, bar); IsolatedStorageSettings.ApplicationSettings[foo] Then

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.