我有关于datediffMYSQL函数的问题,我可以使用它而且很简单.但我不明白如何使用它来收集表字段内的差异.例如
我有一个列dob,我想编写一个类似的查询
select dateDiff(current_timeStamp,dob)
from sometable 'here dob is the table column
Run Code Online (Sandbox Code Playgroud)
我的意思是我希望从当前日期时间到表字段dob的差异,每个查询结果是差异,用户的年龄.
我已经通过核心位置制作了一个单独的类来获取位置.现在我的问题是我想知道位置何时更新.我想在此使用委托而不是通知.我知道我可以发布通知.但我根本不想使用通知.有没有其他方法可以做到这一点,或者只有我的解决方案是NSNotifications.
这是一些代码
//Initilizer
+ (LocationController *)locationManager;
//How I want to be informed using delegates
id<locationControllerDelegate> delegate;
//Instead what I am being forced to use since I dont know how to use delegates with singleton :(
[[NSNotificationCenter defaultCenter] postNotificationName:@"updated" object:nil];
Run Code Online (Sandbox Code Playgroud)
谢谢.
编辑1:
在典型的委托和简单的课程中,我们喜欢这样
someClass *somecls = [[someClass alloc] init];
somecls.delegate = self
Run Code Online (Sandbox Code Playgroud)
但在单身人士中,我们不做任何类的实例
[[LocationController locationmanager] startUpdateLocation];
Run Code Online (Sandbox Code Playgroud)
所以在这种情况下我将如何设置单例类的委托