我在哪里可以下载WWDC 2010代码示例?我是一名注册的iPhone开发人员,但似乎无法在Apple的网站上找到样本.
使用SQLalchemy我想执行左外连接并过滤掉在连接表中具有匹配项的行.
我正在发送推送通知,所以我有一张Notification桌子.这意味着我还有一个ExpiredDeviceId表来存储不再有效的device_ids.(我不想只删除受影响的通知,因为用户以后可能会重新安装应用程序,此时通知应根据Apple的文档恢复.)
CREATE TABLE Notification (device_id TEXT, time DATETIME);
CREATE TABLE ExpiredDeviceId (device_id TEXT PRIMARY KEY, expiration_time DATETIME);
Run Code Online (Sandbox Code Playgroud)
注意:每个device_id可能有多个通知.每个设备都没有"设备"表.
所以在做的时候SELECT FROM Notification我应该相应地过滤.我可以在SQL中做到这一点:
SELECT * FROM Notification
LEFT OUTER JOIN ExpiredDeviceId
ON Notification.device_id = ExpiredDeviceId.device_id
WHERE expiration_time IS NULL
Run Code Online (Sandbox Code Playgroud)
但是我怎么能在SQLalchemy中做到这一点?
sess.query(
Notification,
ExpiredDeviceId
).outerjoin(
(ExpiredDeviceId, Notification.device_id == ExpiredDeviceId.device_id)
).filter(
???
)
Run Code Online (Sandbox Code Playgroud)
或者我可以用一个device_id NOT IN (SELECT device_id FROM ExpiredDeviceId)子句做到这一点,但这似乎效率低下.
如果我使用[UIImage imageWithCGImage:],传入a CGImageRef,然后释放CGImageRef或者UIImage在解除分配时自己处理吗?
文档并不完全清楚.它说"这种方法不会缓存图像对象."
最初我CGImageRelease在传递给CGImageRef后调用它imageWithCGImage:,但是malloc_error_break在模拟器中发出警告声称发生了双重自由.
将以下内容作为布尔表达式的"正确"方法是什么?
for i in `ls $1/resources`; do
if [ $i != "database.db" ]
then
if [ $i != "tiles" ]
then
if [ $i != "map.pdf" ]
then
if [ $i != "map.png" ]
then
svn export -q $1/resources/$i ../MyProject/Resources/$i
...
Run Code Online (Sandbox Code Playgroud) 我的应用程序连接到施瓦布OFX服务器使用NSURLConnection.不幸的是,服务器使用了最新的中间证书,该证书在Mac桌面上是可信任的,但还不是iPhone.(尝试使用URL - 您将在iPhone上获得证书错误.)
没有简单的方法可以NSURLConnection忽略我所知道的无效证书.因此,我试图手动将证书导入Keychain并设置其信任级别,但我遇到了阻塞.
我SecCertificateCreateWithData成功调用从.cer文件导入证书.然后在桌面上我会调用SecTrustSettingsSetTrustSettings,但iPhone SDK中不存在.
任何解决方法?
我有这样的类层次结构:
struct Vehicle {
virtual string model() = 0; // abstract
...
}
struct Car : public Vehicle {...}
struct Truck : public Vehicle {...}
Run Code Online (Sandbox Code Playgroud)
我需要保留std::map一些关于某些Vehicle实例的信息:
std::map<Vehicle, double> prices;
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
/usr/include/c++/4.2.1/bits/stl_pair.h: In instantiation of ‘std::pair<const Vehicle, double>’:
/usr/include/c++/4.2.1/bits/stl_map.h:349: instantiated from ‘_Tp& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) [with _Key = Vehicle, _Tp = double, _Compare = std::less<Vehicle>, _Alloc = std::allocator<std::pair<const Vehicle, double> >]’
test.cpp:10: instantiated from here
/usr/include/c++/4.2.1/bits/stl_pair.h:73: error: cannot declare field ‘std::pair<const Vehicle, double>::first’ to be …Run Code Online (Sandbox Code Playgroud) 想象一下,我有抽象的基类 Shape,派生类Circle和Rectangle.
class Shape {};
class Circle : public Shape {};
class Rectangle : public Shape {};
Run Code Online (Sandbox Code Playgroud)
我需要确定两个形状是否相等,假设我有两个Shape*指针.(这是因为我有两个实例,vector<Shape*>我想看看它们是否具有相同的形状.)
建议的方法是双重调度.我想出的就是这个(这里大大简化了,所以形状等于同一类型的所有其他形状):
class Shape {
public:
virtual bool equals(Shape* other_shape) = 0;
protected:
virtual bool is_equal(Circle& circle) { return false; };
virtual bool is_equal(Rectangle& rect) { return false; };
friend class Circle; // so Rectangle::equals can access Circle::is_equal
friend class Rectangle; // and vice versa
};
class Circle : public Shape …Run Code Online (Sandbox Code Playgroud) 在Cocoa中,特别是iPhone SDK,该opaque属性被描述为:
如果不透明,则绘制操作假定视图填充其边界并且可以更有效地绘制.如果不透明且视图未填充其边界,则结果是不可预测的.如果视图完全或部分透明,请将此属性设置为NO.
根据我的经验,如果你有一个视图(标签,表格单元格,等)backgroundColor设置为[UIColor clearColor],你就不会需要设置opaque到NO它能够正确显示(有明显的背景).
直觉上,这样做也需要将NO设置为不透明,但我从来没有遇到过问题.
你可以混合opaque = YES和clearColor,还是我靠借来的时间生活?它似乎没有具体记录在任何地方.
在Cocoa中,addObserver:forKeyPath:options:context:保留"既不是接收者,也不是观察员".因此我假设允许观察自我; 也就是说,做类似的事情是完全有效的
[self addObserver:self forKeyPath...]
只要你记得以selfdealloc作为观察者取消注册.
这个假设是否正确?
通过快速枚举来枚举是否安全[NSOperationQueue operations]?像这样:
for (NSOperation *op in [operationQueue operations]) {
// Do something with op
}
Run Code Online (Sandbox Code Playgroud)
由于操作是异步的并且在另一个线程上执行,operations因此可以随时更改(包括在主线程执行期间).快速枚举是否可以防止这种情况,或者我应该copy(和autorelease)操作数组?
cocoa cocoa-touch nsoperation fast-enumeration nsoperationqueue
cocoa-touch ×5
cocoa ×4
c++ ×2
bash ×1
expression ×1
inheritance ×1
iphone ×1
join ×1
keychain ×1
map ×1
nsoperation ×1
oop ×1
polymorphism ×1
python ×1
shell ×1
sql ×1
sqlalchemy ×1
stl ×1
wwdc ×1