Question: Are there any libraries to parse Textile (Textile to HTML) which will work in an Objective C iPhone app? C libraries will work too.

**Update:** I couldn't find any sufficiently developed libraries in C/Obj-C, but I did find one written in Javascript, which I used through an invisible UIWebView.

Link: [Javascript textile parser](http://jrm.cc/extras/live-textile-preview.php)

Answer: 
Of course a method can return NSRange. But returning structures require special attention to the compiler because how the method is invoked is usually different (`objc_msgSend_stret` vs. `objc_msgSend`). 

Please make sure you declare `phrase` as

```
Phrase* phrase = ...;

```

so that the compiler knows `-rangeInString:…` is returning an NSRange, instead of 

```
id phrase = ...;

```

(Also, since you don't show which line the compiler errors, make sure the function using `return … == -1;` is returning a BOOL not NSRange.)
> 
> Can a method return an NSRange?
> 
> 
> 

Yes.

> 
> This method is called within the Phrase object by other methods without problems. … When I call this method from outside the class I get a compile error. … The compiler says 'incompatible types in assignment'.
> 
> 
> 

Remember to `#import` Phrase.h into the implementation file where you're talking to a Phrase object. Otherwise, the compiler doesn't know about your `rangeOfString:forString:goingForward:` method and *assumes* that it returns `id`. It needs the `@interface` in the header file to *know* that the method returns `NSRange`.

Assuming that your phrase object is in an instance variable, you probably declared the Phrase class with `@class Phrase;` in the header file where you declared the ivar. That's a forward declaration; it tells the compiler that a class named “Phrase” exists (so that a declaration like `Phrase *myPhrase` will be legal), but it doesn't tell the compiler anything else about it. To do that, you need to import the header.

The general rule, for instances of class A knowing about instances of class B, is for A's header (A.h) to forward-declare class B with `@class`, and A's implementation (A.m) to import B's header (B.h).

A different case is when A is a subclass of B. You need the `@interface` to make a subclass, so in this case and this case only, A.h must import B.h. Since it's importing the header for B, it does not need to forward-declare B.