discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to enable "shorthand" access element in NSArray


From: David Chisnall
Subject: Re: How to enable "shorthand" access element in NSArray
Date: Sun, 28 Dec 2014 11:47:42 +0100

Are you targeting the non-fragile ABI?  This array accessor notation is a 
terrible idea, so I'd recommend that you avoid it, as it (along with the 
property notation) destroy one of the key strengths of Objective-C: the 
orthogonality of syntax.  In particular, with the fragile ABI, you were allowed 
to allocate C arrays of objects, so myArray[1] means *(&myArray + 1).  It looks 
like that's what you're getting here, because the result of this will be an 
NSArray (not an NSArray*), which is incompatible with an id.

And are you sure that you're using clang?  That looks very much like a GCC 
error...

David

On 28 Dec 2014, at 11:40, Rael Bauer <support@bauerapps.com> wrote:

> Hi,
> 
> I am using GNUStep on Windows with the clang compiler.
> 
> From what I have read, I should be able to access NSArray elements with 
> following ("universal"...) notation
> 
> myArray[index]
> 
> instead of the expanded:  [myArray objectAtIndex:1]
> 
> However, when I try the shorthand, I receive an error message from the 
> compiler:
> 
> e.g.
> 
>    NSArray * myArray = @[@"A", @"B", @"C"];
>    NSLog(myArray[1]);
> 
> error:
> passing 'NSArray' to parameter of incompatible type 'id'
> 
> Is there something special I need to do to enable this notation? (compile 
> flag?) (Is it a problem on Windows?)
> 
> Thanks
> Rael
> 
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep


-- Sent from my Apple II




reply via email to

[Prev in Thread] Current Thread [Next in Thread]