如果我创建了NSManagedObject Subclass的子类,我会在实现文件Business.m上看到这些函数(例如)
这些函数都没有在头文件Business.h中声明.我必须亲自补充一下
- (void)addDistrictsObject:(District *)value;
- (void)addCategoriesObject:(Category *)value;
- (void)addReviewsObject:(Review *)value;
Run Code Online (Sandbox Code Playgroud)
我想知道为什么我必须手动添加这些声明?当我尝试生成SubClass时为什么不自动?
以下是功能:
- (void)addPromotionsObject:(Promotion *)value {
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
[self willChangeValueForKey:@"Promotions" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[[self primitiveValueForKey:@"Promotions"] addObject:value];
[self didChangeValueForKey:@"Promotions" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[changedObjects release];
}
- (void)removePromotionsObject:(Promotion *)value {
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
[self willChangeValueForKey:@"Promotions" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
[[self primitiveValueForKey:@"Promotions"] removeObject:value];
[self didChangeValueForKey:@"Promotions" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
[changedObjects release];
}
- (void)addPromotions:(NSSet *)value {
[self willChangeValueForKey:@"Promotions" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
[[self primitiveValueForKey:@"Promotions"] unionSet:value];
[self didChangeValueForKey:@"Promotions" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
} …Run Code Online (Sandbox Code Playgroud) 属性"Latitude"是"LatitudeLongitude"类的标量类型.无法为其生成setter方法.
当我为托管对象生成代码时,我收到一条消息,我是否想要原始数据类型的标量属性.我应该用吗?我想让这个应用程序与iPhone 3 - 5兼容
这个问题有什么问题吗?
图像可以是任何东西.它可以是jpg,png,任何东西.
加载它.
裁剪它.假设从左侧删除前100个像素.
保存到同一个文件
我们如何知道方法是否是线程安全的
例如,如果我查看http://msdn.microsoft.com/en-us/library/3wcytfd1.aspx,则没有任何内容表明其线程安全性.
使用终身限定符来避免强引用周期
您可以使用生命周期限定符来避免强引用周期.例如,通常如果您有一个以父子层次结构排列的对象图表,并且父母需要引用他们的孩子,反之亦然,那么您将使父母与子女之间的关系变得强大,并且父母与子女之间的关系变弱.其他情况可能更微妙,特别是当它们涉及块对象时.
在手动参考计数模式下,
__block id x;具有不保留的效果x.在ARC模式下,__block id x;默认为保留x(就像所有其他值一样).要在ARC下获得手动引用计数模式行为,您可以使用__unsafe_unretained __block id x;.正如其名称__unsafe_unretained所暗示的,然而,具有非保持着的变量是危险的(因为它可以吊着),因此不鼓励.两个更好的选择是使用__weak(如果您不需要支持iOS 4或OS X v10.6),或将__block值设置nil为打破保留周期.
好的,__block变量有什么不同?
为什么要到nil这里?是__block可变的保留两次?谁持有所有参考?块?堆?堆栈?线程?什么?
以下代码片段使用有时在手动引用计数中使用的模式说明了此问题.
MyViewController *myController = [[MyViewController alloc] init…];
// ...
myController.completionHandler = ^(NSInteger result) {
[myController dismissViewControllerAnimated:YES completion:nil];
};
[self presentViewController:myController animated:YES completion:^{
[myController release];
}];
Run Code Online (Sandbox Code Playgroud)
如上所述,您可以使用__block限定符并nil在完成处理程序中将myController变量设置为:
MyViewController * __block myController = [[MyViewController alloc] init…]; //Why …Run Code Online (Sandbox Code Playgroud) NSString * strNil= [NSString stringWithFormat:@"%@",nil];
Run Code Online (Sandbox Code Playgroud)
结果是strNil是@"null"
好吧,我希望它是@""
我想要一个优雅的解决方案.我知道我可以创建emptyStringIfNil类别方法.但这不起作用,因为该函数将返回nil,而不是@"".
你为此做了什么?
基本上我想要这样的陈述
NSString * result =[NSString stringWithFormat:@"http://%@/business/api/addOrEditBusiness.php?flag=%@&title=%@&building=%@&latitude=%@&longitude=%@&website=%@&street=%@&city=%@&country=%@%@&originalid=%@&inbuildingaddress=%@&email=%@&zip=%@%@&userid=%@%@",urlServer,strFlag,biz.Title.RobustURLEncodedString,biz.buildingName.RobustURLEncodedString,@(coord.latitude),@(coord.longitude),biz.Website.RobustURLEncodedString,biz.Street.RobustURLEncodedString, biz.City.Name.RobustURLEncodedString, biz.City.Country.Name.RobustURLEncodedString,strPhonesParameter,biz.ID.RobustURLEncodedString,biz.InBui
Run Code Online (Sandbox Code Playgroud)
每次字符串为零时显示为空
例如,如果streetAddress为nil,我想要&street =&city = Tokyo而不是street =(null)&city = Tokyo
我洒了
NSAssert(abs(self.frame.size.height-self.contentView.frame.size.height)<=1,@"Should be the same");
Run Code Online (Sandbox Code Playgroud)
在创建UITableViewCell返回时的各个地方.
结果往往不同.有时候是1像素,有时是2.
我想知道问题是什么?在cellForRowAtIndexPath中有什么东西让它们与众不同吗?
他们的开始是一样的.没有编辑等
看看这个简单的snipet
BGDetailTableViewCell * cell= (BGDetailTableViewCell*)[tableView dequeueReusableCellWithIdentifier:[BGDetailTableViewCell reuseIdentifier]];
if (cell==nil)
{
cell = [[BGDetailTableViewCell alloc]init];
}
else
{
NSAssert(abs(cell.frame.size.height-cell.contentView.frame.size.height)<=1,@"Should be the same"); //Sometimes this fail
}
NSOrderedSet *Reviews = [self.businessDetailed mutableOrderedSetValueForKey:footer.relationshipKey];
Review * theReview = [Reviews objectAtIndex:row];
cell.theReview = theReview;
NSAssert(abs(cell.frame.size.height-cell.contentView.frame.size.height)<=1,@"Should be the same");//This one never fail right before returning cell
return cell;
`NSAssert(abs(cell.frame.size.height-cell.contentView.frame.size.height)<=1,@"Should be the same")`; never fails right before returning the cell.
Run Code Online (Sandbox Code Playgroud)
然而,在我有时将细胞出列后,它失败了.
这是结果
(lldb) po cell
$0 = 0x0c0f0ae0 …Run Code Online (Sandbox Code Playgroud) - (void)viewDidLoad
{
[super viewDidLoad];
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
self.edgesForExtendedLayout = UIRectEdgeNone;
self.navigationController.navigationBar.translucent=YES;
}
// Do any additional setup after loading the view.
}
Run Code Online (Sandbox Code Playgroud)
我不希望我的scrollView默认位于navigationBar的后面.所以我设置了self.edgesForExtendedLayout = UIRectEdgeNone;.
那个viewDidLoad是我所有viewController的母viewDidLoad.
没关系.但我喜欢半透明的效果.
当我将self.edgesForExtendedLayout设置为none时,似乎半透明效果消失了.
如何将其设置为无,仍然具有半透明效果.


我认为一个好的解决方案是安排scrollview的插图.
我做到了
- (void)viewDidLoad
{
[super viewDidLoad];
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
//self.edgesForExtendedLayout = UIRectEdgeNone;
self.navigationController.navigationBar.translucent=YES;
self.automaticallyAdjustsScrollViewInsets = YES;
}
// Do any additional setup after loading the view.
}
Run Code Online (Sandbox Code Playgroud)
这就是我得到的:

通常我将数据存储在一个数组中.然后,当调用cellForRowAtIndexPath时,我只看行,并根据行和进程选择数组上的项.
但是我们所知道的UITableView可以进行组视图.
所以我该怎么做?
我应该有一个数组数组吗?数组的NSDictionary?在UITableView结构中存储数据的最优雅方式是什么?
一些答案似乎表明我应该使用 SHDocVw.InternetExplorerMedium 来实现 Internet Explorer 自动化。
Internetexplorer 媒体和 Internet Explorer 之间有什么区别?
我尝试运行此代码,但出现对象断开连接异常
ias.IntExpMed = New SHDocVw.InternetExplorerMedium
ias.IntExpMed.Navigate("http://wikipedia.com")
waitTing(1)
ias.IntExpMed.Navigate("http://google.com")
Run Code Online (Sandbox Code Playgroud)
实际上,如果我逐步执行该程序,该对象将在之后立即断开连接
ias.IntExpMed.Navigate("http://wikipedia.com")
Run Code Online (Sandbox Code Playgroud) objective-c ×6
vb.net ×2
xcode ×2
xcode4.5 ×2
.net ×1
automation ×1
collections ×1
core-data ×1
crop ×1
generics ×1
image ×1
ios7 ×1
iphone-4 ×1
nsobject ×1
properties ×1
scalar ×1
shdocvw ×1
uitableview ×1
xcode4.3 ×1