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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top