小编ric*_*ira的帖子

如何在Cocoa应用程序中收到系统时间更改的通知?

我有一个Cocoa应用程序,记录事件的日期戳.我需要知道系统时间何时重置以及重置多少,但我似乎无法在任何告知我发生过这种情况的通知.这种变化可能发生,因为NTP重置时钟或因为用户重置(例如从系统偏好设置).如果NSNotification我能注册接收会很好,但我愿意接受任何建议.

cocoa nsnotifications

9
推荐指数
2
解决办法
4386
查看次数

通知点击事件时的通话活动

我想在用户下拉通知并点击该通知时调用该活动...我该怎么做?

android push-notification

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

观察macOS中系统日期/时间的变化

我是iOS开发人员.在iOS上,我们可以applicationSignificantTimeChange:在我们的app委托中实现该方法,或者注册UIApplicationSignificantTimeChangeNotification通知以响应系统时间的变化.

我似乎无法在Mac上找到同等产品.如何在macOS中观察系统时间的显着变化(例如:用户更改时间(区域),从/到夏令时切换)(除了启动每秒触发一次的计时器)?

macos time cocoa datetime date

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

swift:如何将超类中的公共方法覆盖为子类中的私有方法

我有一个超级班

class Father {
    public func doSomething() {
    } 
}
Run Code Online (Sandbox Code Playgroud)

我想要这个儿童班

class Child: Father {
    private override func doSomething() {
    }
}
Run Code Online (Sandbox Code Playgroud)

但Xcode说

重写实例方法必须与它覆盖的声明一样可访问

那么,如何覆盖超类中的公共方法是子类中的私有方法

谢谢

inheritance swift

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

@main 和 @uiapplicationmain 有什么区别

我需要帮助了解何时使用@mainvs @uiapplicationmain

据我所知,@uiapplicationmain这是一种更简单的调用方法,uiapplicationmain(:::)其中将之后创建的类@uiapplicationmain用作应用程序委托。我还知道它还会创建一个UIApplication.

我还知道应用程序委托成为项目的入口点。

从我读到的内容来看,我被告知这@main也是一个入口点,但它需要一个主函数。

我想知道的是主入口点是什么意思。就像 Xcode 所做的那样使其成为“入口”点。整个事情是如何工作的,比如它与 Xcode 运行代码的方式@main有何不同以及它做了什么。@uiapplicationmain

uikit swift

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

什么是hh和h格式说明符的需要?

使用hhx而不是x有什么用,在下面的代码中,mac_str是char指针macuint8_t数组,

 sscanf(mac_str,"%x:%x:%x:%x:%x:%x",&mac[0],&mac[1],&mac[2],&mac[3],&mac[4],&mac[5]);
Run Code Online (Sandbox Code Playgroud)

当我尝试上面的代码时它发出警告,

warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 8 has type ‘uint8_t *’ [-Wformat]
Run Code Online (Sandbox Code Playgroud)

但我在他们指定的一些代码中看到了

sscanf(str,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",&mac[0],&mac[1],&mac[2],&mac[3],&mac[4],&mac[5]);
Run Code Online (Sandbox Code Playgroud)

哪个不给任何警告

但两者都是一样的,使用hhx而不是x的需要是什么,我在网上搜索但没有直接回答

c scanf format-specifiers

8
推荐指数
2
解决办法
6813
查看次数

UITabBar在iOS7上更改一个UITabBarItem的背景颜色

我可以改变一个特定的背景颜色UITabBarItemUITabBar

我知道如何更改所选背景的所有背景,使用:

[[UITabBar appearance] setBarTintColor:[UIColor redColor]];
[[UITabBar appearance] setTintColor:[UIColor blueColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor yellowColor]];
Run Code Online (Sandbox Code Playgroud)

但是如果没有子类化,它只能用于一个项吗?

谢谢

objective-c uitabbaritem uitabbar ios ios7

7
推荐指数
2
解决办法
8685
查看次数

如何在 tableView:heightForRowAtIndexPath: 中初始化 NSAttributedString: 是隐式递归的?

我在计算 a 的高度时遇到了一个非常奇怪的问题UITableViewCell

似乎如果我实例化一个包含一些 HTML的NSAttributedStringwith NSData,则会在当前视图上强制执行一个布局循环,最终会tableView:heightForRowAtIndexPath:再次调用。而且,在此传递中要求所有其他行的高度。幸运的是,行高请求的内部循环中没有另一组递归调用。

这是堆栈跟踪:(注意第 0 帧和第 25 帧)

#0  0x0024422c in -[FeedVC tableView:heightForRowAtIndexPath:] at /Users/me/project/Classes/controllers/FeedVC.m:371
#1  0x024516cc in __66-[UISectionRowData refreshWithSection:tableView:tableViewRowData:]_block_invoke ()
#2  0x02450fd9 in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] ()
#3  0x02455e2f in -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] ()
#4  0x02455f40 in -[UITableViewRowData heightForTable] ()
#5  0x022c68c2 in -[UITableView _adjustExtraSeparators] ()
#6  0x022da6d3 in -[UITableView layoutSubviews] ()
#7  0x0225a964 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#8  0x040d582b in -[NSObject performSelector:withObject:] ()
#9  0x01f7145a in -[CALayer layoutSublayers] ()
#10 …
Run Code Online (Sandbox Code Playgroud)

uitableview nsattributedstring ios

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

UIApplicationLaunchOptionsShortcutItemKey在Swift 3中没有?

最近在Xcode 8 beta 6(8S201h)中,这已经成为一个问题.

 UIApplicationLaunchOptionsShortcutItemKey
Run Code Online (Sandbox Code Playgroud)

这是错误:

在此输入图像描述

还有谁有相同的问题吗?

var performShortcutDelegate = true
if let shortcutItem = launchOptions[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {
    print("ok")
    self.shortcutItem = shortcutItem
    performShortcutDelegate = false
}
return performShortcutDelegate
Run Code Online (Sandbox Code Playgroud)

swift 3dtouch swift3 xcode8 xcode8-beta6

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

如何为所有模拟器启用/禁用"显示为运行目标"

是否可以切换多个iOS模拟器的" 显示为运行目标 "标志,而不是在" 设备和模拟器 "窗口中逐个更改?是否有一个具有该目的的命令行

在此输入图像描述

xcode ios-simulator

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