Pregunta

I am trying to write this without dot notation but can't figure it out:

[[textField text] rangeOfCharacterFromSet:someInstanceVar].location

I keep getting bad receiver type NSRange (aka '_struct NSRange')

Is this not possible?

Kind regards

¿Fue útil?

Solución

You cannot call that without the dot. rangeOfCharacterFromSet returns a NSRange, which is a plain C struct:

typedef struct _NSRange {
    NSUInteger location;
    NSUInteger length;
} NSRange;

and not an Objective-C object. .location accesses the first member of that struct and is pure C syntax. That has nothing to do with the dot-notation for properties, or with method calls.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top