小编ste*_*anB的帖子

与UIFont和UIColor相关的新手问题

我有几个与UIColor和UIFont有关的问题.

  1. 我想知道如果我在启动时分配一堆UIFonts和UIColors,那么它在系统上有多重,我需要在应用程序运行期间.

  2. 在运行时创建UIFont和UIColor是否昂贵?如果我预先分配相同的内容,它会以任何方式提高性能.

iphone cocoa-touch

1
推荐指数
1
解决办法
594
查看次数

如何在smtpd.SMTPServer.process_message中拒绝收件人?

假设您在重写的类中处理消息,例如:

class MailProcessorServer(smtpd.SMTPServer):
  def process_message(self, peer, sender, rcpttos, data):
    badrecipients = []
    for rcpt in rcpttos:
      badrecipients.append(rcpt)

    #Here I want to warn the sender via a bounced email
    # that the recipient does not exist
    raise smtplib.SMTPRecipientsRefused(badrecipients)
    #but this just crashes the process and eventually the sender times out,
    # not good enough
Run Code Online (Sandbox Code Playgroud)

我只想立即回复发件人.相反,发送服务(比如GMail)最终会放弃,并在几小时后警告用户.该文件似乎很稀疏.

python email smtp

1
推荐指数
1
解决办法
1901
查看次数

在iPhone中的NSMutableArrary中排序

我正在解析XML并以Dictionary的形式将所有数据存储在NSMutableArray中.

NSMutableArray * stories;   

// a temporary item; added to the "stories" array one at a time,
// and cleared for the next one
NSMutableDictionary * item;

- (void)parser:(NSXMLParser *)parser
 didEndElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI 
 qualifiedName:(NSString *)qName
{       
    if ([elementName isEqualToString:@"item"])
    {
        // save values to an item, then store that item into the array...
        [item setObject:currentTitle forKey:@"title"];
        [item setObject:currentLink forKey:@"link"];
        [item setObject:currentSummary forKey:@"summary"];
        [item setObject:currentDate forKey:@"date"];

        //Numeric value for sorting
        [item setObject:rates forKey:@"rates"];

        [stories addObject:[item copy]];    
    }
}
Run Code Online (Sandbox Code Playgroud)

完成解析后,我需要按"rate"排序数组,这是数字字段.请建议.

sorting iphone cocoa cocoa-touch objective-c

1
推荐指数
1
解决办法
536
查看次数

在Objective-c或iPhone编程中,"MyIdentifier"是什么意思

我对以下行"静态NSString*MyIdentifier = @"MyIdentifier";"感到困惑 在方法中:cellForRowAtIndexPath

那条线做什么?它只是创建一个指向NSString对象的随机指针并为其分配字符串吗?为什么它被称为MyIdentifier,我在很多例子中都看到了这一点.

#import "AddToFavorites.h"


@implementation AddToFavorites

- (id)initWithStyle:(UITableViewStyle)style {
  if (self = [super initWithStyle:style]) {
  }
  return self;
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  return 1;
}


- (NSInteger)tableView:(UITableView *)tableView 
numberOfRowsInSection:(NSInteger)section {
  return 5;
}


- (UITableViewCell *)tableView:(UITableView *)tableView 
cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *MyIdentifier = @"MyIdentifier";

UITableViewCell *cell = [tableView 
dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero 
reuseIdentifier:MyIdentifier] autorelease];
}
// Configure the cell

return cell;
}

@end
Run Code Online (Sandbox Code Playgroud)

这是另一个例子,这个有一个不同的字符串CellIdentifier.

- (UITableViewCell *)tableView:(UITableView *)tableView …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uitableview

0
推荐指数
1
解决办法
786
查看次数

标签 统计

cocoa-touch ×3

iphone ×3

objective-c ×2

cocoa ×1

email ×1

python ×1

smtp ×1

sorting ×1

uitableview ×1