小编Mar*_*ark的帖子

CoreData:将图像存储到DB还是不存储?

我正在制作一个应用程序,从网站上获取一些用户名的照片,并在用户名的UITable中显示,然后点击用户名,它显示该用户的照片,然后点击它显示全屏照片的照片名称.

我的问题是我正在使用NSData从互联网上获取照片.我是否必须将数据保存到CoreData?当按下用户名时,它会创建NSData并从互联网下载照片并在UITable上显示.这需要时间.

什么是好方法?以及如何将此图像保存到CoreData?

我正在使用这种方法

NSData *imageData=[flickr dataForPhotoID:firstPhoto.id fromFarm:firstPhoto.farm 
onServer:firstPhoto.server withSecret:firstPhoto.secret inFormat: 
FlickrFetcherPhotoFormatSquare];
Run Code Online (Sandbox Code Playgroud)

这里定义dataForPhotoID方法

- (NSData *)dataForPhotoID:(NSString *)photoID fromFarm:(NSString *)farm   
   onServer:(NSString *)server withSecret:(NSString *)secret 
 inFormat:(FlickrFetcherPhotoFormat)format {

#if TEST_HIGH_NETWORK_LATENCY
sleep(1);
#endif

NSString *formatString;

switch (format) {
    case FlickrFetcherPhotoFormatSquare:    formatString = @"s"; break;
    case FlickrFetcherPhotoFormatLarge:     formatString = @"b"; break;
}

NSString *photoURLString = [NSString stringWithFormat:@"http://farm%@.static.flickr.com/%@/%@_%@_%@.jpg", farm, server, photoID, secret, formatString];
NSURL *url = [NSURL URLWithString:photoURLString];

return [NSData dataWithContentsOfURL:url];
}
Run Code Online (Sandbox Code Playgroud)

iphone image core-data

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

iOS:澄清不同的搜索路径

XCode构建设置中有三种不同的搜索路径:

  • 框架搜索路径
  • 标题搜索路径
  • 图书馆搜索路径

任何人都可以澄清这些路径做什么以及它们用于什么?

xcode build-settings ios ios-frameworks

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

becomeFirstResponder在iOS 8中不起作用

我正在使用UITextField的方法becomeFirstResponder来显示键盘.这适用于iOS 7.但在iOS 8中,此方法不显示键盘.

 UITextField *txtAddNew = [[UITextField alloc] initWithFrame:CGRectMake(10,10,240, 21)];
 txtAddNew.font = [UIFont fontWithName:@"Helvetica" size:16];
 txtAddNew.clearButtonMode = UITextFieldViewModeWhileEditing;
 txtAddNew.returnKeyType = UIReturnKeyDone;
 txtAddNew.delegate = self;
 txtAddNew.autocorrectionType = UITextAutocorrectionTypeNo;
 txtAddNew.tag = 15;

 // Open keyboard
 [txtAddNew becomeFirstResponder];
Run Code Online (Sandbox Code Playgroud)

在iOS 8中有什么办法吗?

iphone ios ios7 ios8 ios8.1

19
推荐指数
2
解决办法
2万
查看次数

您希望在2年前了解Cocoa/Core Foundation辅助功能的哪些功能?

我刚刚在NSGeometry.h中发现了NSRect辅助函数(即NSMidX,NSMaxX等...)

这些将使一些重复编码更容易.我知道NSMakeRect,NSMouseInRect,NSOffsetRect和许多其他人,但不知何故错过了有助于重新计算NSRect几何的函数.

cocoa objective-c

13
推荐指数
2
解决办法
2254
查看次数

使用git commit -a -m时不想使用双引号

当我使用git commit时,我有点厌倦了使用双引号

git commit -a -m "fix xxx error"
Run Code Online (Sandbox Code Playgroud)

当我设置这样的别名:

coam = "!f() { git commit -a -m $1; }; f"
Run Code Online (Sandbox Code Playgroud)

它在我输入时有效

git coam fix
Run Code Online (Sandbox Code Playgroud)

它承诺为

git commit -a -m "fix"
Run Code Online (Sandbox Code Playgroud)

但是如何设置一个可以处理的命令

git commit -a -m "fix xxx error"
Run Code Online (Sandbox Code Playgroud)

当我打字的时候

git coam fix xxx error
Run Code Online (Sandbox Code Playgroud)

我测试一下

coam = "!f() { git commit -a -m $*; }; f"
Run Code Online (Sandbox Code Playgroud)

但它不起作用!

谢谢!

git bash shell

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

Objective-C:有时缺少NSArray的第一项

我有和NSArray有5个字符串元素,填充我的iPhone应用程序的UITableView.

一切正常,但有时我的数组的第一个字符串丢失,我无法弄清楚为什么.

这是我的代码:

arrayList = [[NSArray alloc] initWithObjects: @"My First String", 
                                              @"My Second String",
                                              @"My Third String",
                                              @"My Forth String",
                                              @"My Fifth Sring",
                                              nil];
Run Code Online (Sandbox Code Playgroud)

有时只是没有显示的元素是My First String

其实我正在使用Cocoa With Love的示例代码.谢谢大家帮助我!

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

#if USE_CUSTOM_DRAWING
    const NSInteger TOP_LABEL_TAG = 1001;
//  const NSInteger BOTTOM_LABEL_TAG = 1002;
    UILabel *topLabel;
//  UILabel *bottomLabel;
#endif

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
    //
    // Create the cell.
    //
    cell = …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c nsstring nsarray

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