我使用我的视图控制器将调度队列维护为属性.我在视图控制器的init方法中创建了一次此队列,并重复使用了几次后台任务.在ARC之前,我这样做:
@property (nonatomic, assign) dispatch_queue_t filterMainQueue;
Run Code Online (Sandbox Code Playgroud)
在init中:
if (filterMainQueue == nil) {
filterMainQueue = dispatch_queue_create("com.myQueue.CJFilterMainQueue", NULL);
}
Run Code Online (Sandbox Code Playgroud)
但是在ARC之后,我不确定这应该仍然是"分配",还是应该是"强"还是"弱".ARC转换器脚本没有改变任何东西,但我不确定一个微妙的错误是否来自这个队列在被使用时可能被解除分配的事实?
使用ARC时,3种类型的属性和调度队列最适合的是什么?
我正在尝试创建NSMutableDictionary的深层副本并将其分配给另一个NSMutableDictionary.字典包含一堆数组,每个数组包含名称,键是字母表(这些名称的第一个字母).因此字典中的一个条目是'A' - >'Adam','Apple'.这是我在书中看到的内容,但我不确定它是否有效:
- (NSMutableDictionary *) mutableDeepCopy
{
NSMutableDictionary * ret = [[NSMutableDictionary alloc] initWithCapacity: [self count]];
NSArray *keys = [self allKeys];
for (id key in keys)
{
id oneValue = [self valueForKey:key]; // should return the array
id oneCopy = nil;
if ([oneValue respondsToSelector: @selector(mutableDeepCopy)])
{
oneCopy = [oneValue mutableDeepCopy];
}
if ([oneValue respondsToSelector:@selector(mutableCopy)])
{
oneCopy = [oneValue mutableCopy];
}
if (oneCopy == nil) // not sure if this is needed
{
oneCopy = [oneValue copy];
}
[ret setValue:oneCopy …Run Code Online (Sandbox Code Playgroud) 新的Facebook应用程序似乎已经废除了网格图标布局,有一个更有趣的自定义导航布局,其中最底部的视图显示所有选项(如个人资料,新闻源,Facebook的消息等)并点击其中一个它们带来了另一种俯瞰顶部的视图.您可以按3行按钮然后再次显示底部视图,但当前视图部分可见.Path应用程序最近也更新以匹配此方案.
重建这个的最佳方法是什么?我搜索过任何开源选项,但还没有找到它们.Three20似乎也不支持这一点.
当我尝试使用UIBarButtonItem的"initWithImage"来初始化导航栏自定义图像时,它会被冲洗并在黑色导航栏上拉伸.这是我创建它的方式:
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"gear.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(showSetting:)];
Run Code Online (Sandbox Code Playgroud)
这是它的样子:

不知道图像是否有问题?我是从我买的一套图标中得到的.
我想创建一个这样的方法:
- (void) checkAndUpdateStringProperty: (NSString **) property{
if (...)
*property = @"whatever";
}
Run Code Online (Sandbox Code Playgroud)
我想用它来传递同一个类的属性:
- (void) somewhereElse{
....
[self checkAndUpdateStringProperty: &self.productName];
}
Run Code Online (Sandbox Code Playgroud)
但这会产生语法错误,说"请求的属性表达式的地址".有什么理由吗?如果我用局部变量替换class属性,它可以正常工作:
- (void) somewhereElse{
NSString *name = nil;
[self checkAndUpdateStringProperty: &name];
}
Run Code Online (Sandbox Code Playgroud) 我正在使用iOS8动态框架,我自己构建并在我的iOS应用程序中链接.它在模拟器和设备上工作正常,但在尝试为其存档Release版本时,我不断收到此错误:
代码签名错误:找不到匹配的配置文件:没有任何有效的配置文件允许指定的权利:com.apple.developer.ubiquity-kvstore-identifier,keychain-access-groups,com.apple.developer.icloud-container-identifiers ,com.apple.developer.icloud-services,com.apple.security.application-groups,com.apple.developer.ubiquity-container-identifiers.CodeSign错误:SDK'iOS 8.3'中的产品类型'Framework'需要代码签名
在应用程序目标 - >构建阶段 - >嵌入框架 - >框架链接在那里,并选中"复制代码签名"复选框.
在框架目标 - >构建设置 - >我已将Provisioning Profile设置为"Automatic",对于Code Sign Identity,在Release下,我正在使用"iOS Distribution"
我有3个不同的应用程序目标,需要构建此框架.
我糊涂了:
框架是否需要在开发人员中心注册自己的AppID?
框架是否需要它自己的配置文件?
框架可以使用iOS应用目标中的相同Entitlements文件吗?
谢谢.
我正在使用UISearchController在UITableView中显示搜索栏和结果.我设法正确设置它,但是当我搜索结果然后选择tableview中的一行,并将新的视图控制器推送到导航堆栈时,我希望搜索栏不再可见.但是,当我尝试这个时,第一个视图控制器中的搜索栏在第二个视图控制器中可见:
if (self.searchController == nil) {
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.searchBar.scopeButtonTitles = @[];
self.searchController.searchBar.delegate = self;
self.tableView.tableHeaderView = self.searchController.searchBar;
}
Run Code Online (Sandbox Code Playgroud)
一种选择是调用self.searchController setActive:NO]内部didSelectRowAtIndexPath:但没有办法在没有每次从中选择搜索结果时关闭搜索栏的分散动画的情况下执行此操作.
有没有人有同样的问题?有没有办法告诉UISearchController在推送时隐藏搜索栏?我在使用UISearchDisplayController时工作正常
uitableview uisearchbar uisearchdisplaycontroller ios uisearchcontroller
我有一个自定义的UITableViewCell,它显示了Person对象的各种属性(由Core Data支持)......一些标签,图像等.我目前强制整个tableview在任何属性更改时重新加载,这显然效率不高.我知道KVO,我应该能够在单元格中的标签中添加一个监听器,以监听Person属性的变化.但我不确定如何实现它,也找不到任何例子.
这是我在UITableView的cellForRowAtIndexPath中通常做的事情:
- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath
{
static NSString *simple = @"CustomCellId";
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:simple];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
for (id findCell in nib )
{
if ( [findCell isKindOfClass: [CustomCell class]])
{
cell = findCell;
}
}
}
Person *managedObject = [self.someArray objectAtIndex: indexPath.row];
cell.namelabel.text = managedObject.displayName;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
细胞连接在IB中.我想检测displayName更改的时间,并只更新名称标签.谢谢
我正在iOS应用程序中进行自动更新订阅IAP.我打算在同一个订阅组中有3个不同的层.在我的测试中,我已经能够成功购买订阅,看到它在沙箱上更新了几次,然后在5或6次尝试后停止.这部分工作正常.但我想尝试从应用程序从一个层升级到更高层.这一次,当我尝试将带有新(升级)productID的SKPayment添加到支付队列时,我首先收到警告"你想要修改你的订阅......",然后我点击继续,我得到一个确认消息,但我也收到SKPaymentQueue: updatedTransactions状态失败的回调.错误说:
"失败的事务错误=错误域= SKErrorDomain代码= 0"无法连接到iTunes Store"UserInfo = {NSLocalizedDescription =无法连接到iTunes Store}
任何想法为什么会发生这种情况,以及是否甚至可以从沙箱测试订阅组更新?如果没有,那你将如何进行测试呢?
我正在使用新的 Swift 5.5 功能来创建异步函数:
@MainActor
@objc func updateStatus() async {
/// do async stuff...
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试从 Objective-C 代码调用此方法时,它不会显示在自动完成中,并且如果我尝试构建它,则会出现构建错误:
if (@available(iOS 15.0, *)) {
CJSubscriptionStatusCheck *backgroundStatusCheck = [[CJSubscriptionStatusCheck alloc] init];
[backgroundStatusCheck updateStatus]; // No visible @interface for 'CJStatusCheck' declares the selector 'updateStatus'
}
Run Code Online (Sandbox Code Playgroud)
我的其他 swift 代码在 Objective-C 上运行良好,因此设置很好,但我不确定“异步”代码如何与 Objective-C 一起使用(如果有的话)。我无法通过我的研究找到这个问题的答案。
谢谢。
objective-c ×5
ios ×4
iphone ×2
uitableview ×2
cocoa ×1
codesign ×1
core-data ×1
facebook ×1
storekit ×1
swift ×1
swift5 ×1
uisearchbar ×1
xcode ×1