考慮到下面的Objective-C例子,它僅僅是一種風格和易讀性的問題,可以保留單獨的語句或將它們捆綁在一起?是否有任何實際的好處?宣佈單個變量是否浪費內存?將聲明合併爲一個聲明還是不合並?
NSDictionary *theDict = [anObject methodToCreateDictionary];
NSArray *theValues = [theDict allValues];
NSString *theResult = [theArray componentsJoinedByString:@" "];
或
NSString *theResult = [[[anObject methodToCreateDictionary] theValues] componentsJoinedByString:@" "];
感謝您的澄清。 – tomchkk