我有这些变量:
place.address
place.city
place.state
place.zip
(其中每一个都与你期望的相同,例如,place.address = 123 main st。和place.city = Chicago)
如何进行设置,使其与字母组合和格式正确。
123 main st.
Chicago, IL 60609
答案 0 :(得分:2)
实施[Place formatAddress]
(假设place
是名为Place
的类的实例):
- (NSString *)formatAddress
{
NSString *str = [NSString stringWithFormat:@"%@\n%@, %@ %@",
self.address, self.city, self.state, self.zip];
return str;
}