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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:59:14+00:00 2026-06-04T16:59:14+00:00

Suppose there is a class: @interface FooBar : NSObject @property(readonly, getter = _getSpace) int**

  • 0

Suppose there is a class:

@interface FooBar : NSObject

@property(readonly, getter = _getSpace) int** space;

@end

The space property is implemented as follows:

@implementation FooBar

int m_space1[256];
int m_space2[256];
int* m_space[2] = { m_space1, m_space2};

-(int **) _getSpace {
    return m_space;
}

@end

Is it then legal to alter the int[2][256] array using:

FooBar * f = [[FooBar alloc] init];
f.space[1][120] = 0;

?

  • 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-04T16:59:16+00:00Added an answer on June 4, 2026 at 4:59 pm

    Yes. You’re returning a pointer, and then modifying a value that’s being pointed to. This is perfectly legitimate. If you don’t want to allow this then you need to add the appropriate const modifiers to the type.

    What’s not legitimate is returning a struct and modifying that struct directly.


    As KennyTM mentioned in the comments, your m_space{,1,2} variables are global variables rather than, as you probably intended, instance variables. The simplest way to fix this is to just put an ivar block in your @implementation, as in

    @implementation FooBar {
        int m_space1[256];
        int m_space2[256];
        int* m_space[2] = { m_space1, m_space2 };
    }
    
    -(int **) _getSpace {
        return m_space;
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose there in an interface Displaceable and a class Circle which implements Displaceable. Displaceable
Suppose I have this annotation class @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface MethodXY { public int
Suppose I have class Foo(db.Model): bar = db.ReferenceProperty(Bar) foo = Foo.all().get() Is there a
Suppose I have a class that implements an interface: public class A implements IB
Suppose the following. There is some superclass or interface declaring some method: Base.doSmth() .
Suppose I have an empty interface class IBaseInterface which is used only to label
Suppose I have: interface Foo { void doStuff(); } class FooImpl implements Foo {
There exists interface Algorithm There exists class MathAlgorythm implements Algorithm (returns MathResult, which implements
There is a design problem like this. Suppose you have a set of class
Suppose I have two classes with the same interface: interface ISomeInterface { int foo{get;

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.