2012-06-12 40 views

回答

7

您可以實現這樣的方法:

- (NSString*)modeToString:(MODE)mode{ 
    NSString *result = nil; 
    switch(mode) { 
     case FRAMED: 
      result = @"FRAMED"; 
      break; 
     case HALFPAGED: 
      result = @"HALFPAGED"; 
      break; 
     case FULLPAGED: 
      result = @"FULLPAGED"; 
      break; 
     default: 
      [NSException raise:NSGenericException format:@"Unexpected MODE."]; 
    } 
    return result; 
} 
0

據我所知,沒有一個內置的方式來做你所問的。

我的做法是這樣的:

- (NSString *)modeString:(MODE)mode 
{ 
    if(mode == FRAMED) 
    { 
     return @"FRAMED"; 
    } 
    else if(mode == HALFPAGED) 
    { 
     return @"HALFPAGED"; 
    } 

    return @"FULLPAGED"; 
}