小编ber*_*ium的帖子

如何在objective-c中看弱和强引用?

维基百科指出"在计算机编程中,弱引用是一种不能保护引用对象免受垃圾收集器收集的引用".这两种类型的引用在代码中是什么样的?弱引用是否是由自动释放的消息引用的?

iphone weak-references objective-c strong-references

14
推荐指数
2
解决办法
8274
查看次数

加密视频文件?

我正在使用此方法加密视频文件:

public static void encryptToBinaryFile(String password, byte[] bytes, File file) throws EncrypterException {
    try {
        final byte[] rawKey = getRawKey(password.getBytes());
        final FileOutputStream ostream = new FileOutputStream(file, false);

        ostream.write(encrypt(rawKey, bytes));
        ostream.flush();
        ostream.close();

    } catch (IOException e) {
        throw new EncrypterException(e);
    }
}

private static byte[] encrypt(byte[] raw, byte[] clear) throws EncrypterException {
    try {
       final SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
       final Cipher cipher = Cipher.getInstance("AES");
       cipher.init(Cipher.ENCRYPT_MODE, skeySpec);

       return cipher.doFinal(clear);

    } catch (Exception e) {
        throw new EncrypterException(e);
    }
}
Run Code Online (Sandbox Code Playgroud)

但它给出了一个错误Outofmemoryerror说拒绝分配301023321元素. …

java encryption android file out-of-memory

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

ios中的临时分发和应用商店分发有什么区别

我是Iphone开发的新手.我对app_store发行有一点了解.我的问题是

1)ios应用程序分发中的临时分发需求是什么?

2)Apple是否需要临时分发任何其他许可证?

如果有人知道,请帮助我.提前致谢.

xcode ad-hoc-distribution ios4 ios

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

CoreData 1570错误代码

目前我的所有保存都将转到内存中,但不会写入磁盘(iOS).我的应用程序设置为UITableView带有一个添加模态视图,用于创建内容,当用户完成创建内容并单击保存按钮时,新项目(由我的CoreData模型创建的NSManagedObject类)我打印出来并且完全填写.在此之后我立即尝试将其保存到磁盘,并生成一个错误消息,其中包含相同的对象ID,但字段为nil.然而,在我之间的UITableViews (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 方法被调用,即记录@"CanEdit".

谁能看到我做错了什么?

这是代码

        NSLog(@"newItem %@", newItem);
    NSError *error;
    if (![newItem.managedObjectContext save:&error]) {
        // Handle the error.
        NSLog(@"%@", error);
    }

    if (editItem) {
        [self.navigationController popViewControllerAnimated:YES];
    } else {
        [self dismissModalViewControllerAnimated:YES];            
    }
Run Code Online (Sandbox Code Playgroud)

这是我的错误

2011-10-22 15:24:46.322 App[42115:fb03] newItem <Item: 0x81a4a30> (entity: Item; id: 0x81a0ab0 <x-coredata:///Item/t7F2B54D2-0DCC-4530-88D5-900BE25C7DC23> ; data: {
    containedIn = "0x6e89010 <x-coredata:///Item/t7F2B54D2-0DCC-4530-88D5-900BE25C7DC22>";
    contains =     (
    );
    content = a;
    dateLastUsed = nil;
    depth = 0;
    encrypted = 0;
    favorite = 0;
    favoritePosition = nil; …
Run Code Online (Sandbox Code Playgroud)

xcode core-data objective-c ios

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

UIPageViewController中的UIButton交互

我在我的应用程序中使用UIPageViewController,我想在其中有一些UIButtons,有点像菜单.我遇到的问题是,当我在屏幕边缘附近放置UIButton(或任何其他交互元素)并点击它时,而不是应用UIButton操作,会发生什么变化,页面会发生变化(因为边缘点击屏幕更改UIPageViewController上的页面).我想知道是否有办法使UIButton具有比UIPageViewController更高的优先级,这样当我点击按钮时,它会应用相应的操作而不是更改页面.

iphone xcode objective-c uipageviewcontroller

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

indexPath.row始终为0

我正在使用一系列字典填充表视图.解析数组和字典的内容没有问题.但是,该表填充了[数组计数]单元格数,其内容具有数组的索引0.在我看来,indexPath.row为所有单元格返回0.如何使用相应的索引填充每个单元格?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}


// Configure the cell...
NSDictionary *term = [self.terms objectAtIndex:indexPath.row];
cell.textLabel.text = [term objectForKey:@"content"];
cell.detailTextLabel.text = [term objectForKey:@"created"];

return cell;
}
Run Code Online (Sandbox Code Playgroud)

非常感谢!

编辑:这是我记录indexPath所得到的

2011-11-21 03:07:58.025演示[21269:f803] 2个索引[0,0]

2011-11-21 03:07:58.027演示[21269:f803] 2个索引[1,0]

似乎第一个索引正在更新,而第二个索引没有.

但是,当我记录indexPath.row时

2011-11-21 03:19:40.306演示[21546:f803] 0

2011-11-21 03:19:40.308演示[21546:f803] 0

那么我应该使用什么来获得递增的值?

再次感谢您的帮助.

objective-c nsindexpath

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

如何使用PhoneGap API保存用户登录凭据?

我想在我的iPhone应用程序中保存用户登录凭据,该应用程序是使用PhoneGap和SenchaTouch API构建的.如果用户通过App登录,我想保存他的userId/Password,除非他专门注销.每次他使用应用程序并添加到用户体验时,这将使他免于登录过程.

任何形式的帮助将不胜感激.

谢谢

iphone autologin sencha-touch cordova

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

Xcode - 错误:无法打开可执行文件.....如何修复?

我的第一个iPhone应用程序已准备好使用Application Uploader提交.我想我明白我必须通过在Xcode中使用Product:Archive来创建文件,但是当我这样做时,我收到以下消息:

错误:无法打开可执行文件'/Users/Library/Developer/Xcode/DerivedData/test-euevazxsqeehnwantvxjhqwkytxr/ArchiveIntermediates/test/InstallationBuildProductsLocation/Applications/test.app/test'

该应用程序在我的手机和模拟器上构建并运行良好,所以我可以就如何解决这个问题提出一些建议吗?谢谢.

xcode build

11
推荐指数
2
解决办法
8977
查看次数

命令/ usr/bin/lipo失败,退出代码1错误

我终于完成了我的应用程序,当这突如其来的错误袭击我并且我不知道该怎么做时,我正准备上传.我已经检查了其他帖子,说要更改代码签名身份,我已经这样做但没有运气.我尝试了身份中的每一个选项,没有任何变化.如果有人知道发生了什么,我会非常感激,因为我只是想提交我的应用程序.

以下是它在erorr日志中所说的内容:

/usr/bin/lipo: /Users/teddy/Library/Developer/Xcode/DerivedData/grocery_stores-dcyubhefhrcjhtcxbhldfpukdgdz/Build/Intermediates/grocery stores.build/Release-iphoneos/grocerystores.build/Objects-normal/armv7/grocery stores and /Users/teddy/Library/Developer/Xcode/DerivedData/grocery_stores-dcyubhefhrcjhtcxbhldfpukdgdz/Build/Intermediates/grocery stores.build/Release-iphoneos/grocery stores.build/Objects-normal/armv7/grocery stores have the same architectures (armv7) and can't be in the same fat output file

Command /usr/bin/lipo failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios

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

自定义iOS推送通知声音

我一直面临一个问题.我在iOS中使用自定义声音实现了推送通知.它是一个MP3文件.当我在iOS 5中收到推送通知时,它会很好地播放,但在iOS4中,它不播放任何声音.你能帮帮我吗?

代码是这样的

{
    "aps": {
        "badge": 10,
        "alert": "Hello",
        "sound": "sound.mp3"
    }
}
Run Code Online (Sandbox Code Playgroud)

尼西

push-notification apple-push-notifications ios

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