我试图序列化SearchEntity
对象(自定义对象)含有NSMutableDictionary
含一组类型的CategoryEntity
(自定义对象).
1 SearchEntity<NSCoding>
包含:1 NSMutableDictionary
(参数)参数,包含X CategoryEntities<NSCoding>
只包含字符串和数字.
在这条线[encoder encodeObject:parameters forKey:kPreviousSearchEntityKey];
的SearchEntity encodeWithCoder"我得到GDB:中断每一次,没有错误消息,异常等只是GDB:中断.
这是SearchEntity
和参数的实现NSMutableDictionary
#pragma mark -
#pragma mark NSCoding delegate methods
- (void) encodeWithCoder:(NSCoder*)encoder
{
//encode all the values so they can be persisted in NSUserdefaults
if (parameters)
[encoder encodeObject:parameters forKey:kPreviousSearchEntityKey]; //GDB:Interrupted!
}
- (id) initWithCoder:(NSCoder*)decoder
{
if (self = [super init])
{
//decode all values to return an object from NSUserdefaults in the same state as when saved …
Run Code Online (Sandbox Code Playgroud) 每当我设置tableHeaderView时,我都没有在模拟器中看到它.如果我将其添加为子视图,它最终会在节标题下面绘制.知道我在这里缺少什么吗?
我有一个XIB文件.我没有看到IB中的任何属性影响headerViews.
- (void)viewDidLoad {
[super viewDidLoad];
MyTitleView *titleView = [[MyTitleView alloc] initWithFrame:CGRectMake(60,0,260,40)];
titleView.label.text = @"My Title";
self.navigationItem.titleView = titleView;
[titleView release];
StandardTableHeaderView *headerView = [[StandardTableHeaderView alloc] initWithFrame:CGRectMake(0,0,320,44)];
self.tableView.tableHeaderView = headerView;
// [self.view addSubview:self.tableView.tableHeaderView];
// [headerView release];
NSLog(@"Header: %@",self.tableView.tableHeaderView); //Logs ] Header: <StandardTableHeaderView: 0x5a508b0; frame = (0 0; 320 44); layer = <CALayer: 0x5a51130>>
Run Code Online (Sandbox Code Playgroud)
编辑:StandardTableHeaderView.m init方法:
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
self.backgroundColor = [UIColor redColor];
self.label = [[UILabel alloc] initWithFrame:CGRectMake(frame.origin.x,0,frame.size.width,frame.size.height)];
self.label.backgroundColor = [UIColor clearColor];
self.label.textColor = …
Run Code Online (Sandbox Code Playgroud) 我有一个名称,地址,电话的对象数组.没有等
我希望能够在数组中搜索任何术语的出现 - 无论是在名称字段,地址字段等.
我有这样的想法:
-(void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope {
// Update the filtered array based on the search text and scope.
// Remove all objects from the filtered search array
[self.searchResults removeAllObjects];
// Filter the array using NSPredicate
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains[c] %@",searchText];
searchResults = [NSMutableArray arrayWithArray:[contactArray filteredArrayUsingPredicate:predicate]];
}
Run Code Online (Sandbox Code Playgroud)
这会导致异常"无法在集合中使用/包含运算符".
UPDATE.我现在可以搜索最多三个字段.当我添加第四个(以任何顺序)时,我得到这个异常:"无法解析格式字符串......"
Predicate代码现在是:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.narrative contains[c] %@ OR SELF.category contains[c] %@ OR SELF.date contains[c] OR SELF.name contains[c] %@", searchText, searchText, searchText, searchText];
searchResults = [NSMutableArray arrayWithArray:[allDreams filteredArrayUsingPredicate:predicate]]; …
Run Code Online (Sandbox Code Playgroud) 我有一个iPhone应用程序,点击按钮它应该打开一个自定义警报视图,在右上角的窗口显示一些文本和"X"十字标志,就像我们在任何Web应用程序的灯箱中一样.
我一直在玩Restkit大约一天,它的复杂性让我感到疯狂.
我在iOS上寻找一个简单,维护良好,安静的客户端,可以与我用rails编写的web服务器进行通信.我只需要以下内容:轻松调用CREATE/UPDATE/DELETE,灵活地检查响应代码以及响应体(我依靠响应体来为我的对象设置某些与服务器相关的ID)
不幸的是,Resty并不"真的支持ARC,所以它现在不在我的领域之内.
有什么建议?
我正在创建一个UIActionSheet
on actionSheet:clickedButtonAtIndex委托方法.
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
if(buttonIndex == 1){
[self.myFirstView removeFromSuperview];
if (!self.mySecondView) {
[[NSBundle mainBundle] loadNibNamed:@"MySecondView" owner:self options:nil];
}
[self.mySecondView setFrame:CGRectMake(0, 0, 320, 480)];
[[UIApplication sharedApplication].keyWindow addSubview: self.mySecondView];
UIActionSheet * action = [[UIActionSheet alloc]initWithTitle:@""
delegate:self
cancelButtonTitle: nil
destructiveButtonTitle: deleteContacts
otherButtonTitles: cancel, nil];
action.tag = 102;
[action showInView:self.view];
[action release];
}
Run Code Online (Sandbox Code Playgroud)
我用UIActionSheet
与上面完全相同的方法处理了click事件.
if(actionSheet.tag == 102){
if(buttonIndex == 0){
if([[NSBundle mainBundle] loadNibNamed:@"MyThirdView" owner:self options:nil]) {
[self.myThirdView setFrame:CGRectMake(0, 0, 320, 480)];
[[UIApplication sharedApplication].keyWindow addSubview:self.myThirdView];
}
[self.mySecondView removeFromSuperview];
[self.doneButton.target …
Run Code Online (Sandbox Code Playgroud) 每当我升级到xCode时,我都会遇到很多次这个问题.它删除了我的旧模拟器,我将再次下载它们.任何人都可以让任何其他过程.那可能是复制旧的模拟器文件夹并将它们粘贴到xCode内容/ Developer/Platform/.....
或者是否存在在本地存储的xCode中添加模拟器的任何过程,而不是再次再次下载它们.
我有一个字符串,例如"Hello world"和一个字体名称,例如"Courier".我需要得到一个代表这个字符串的折线数组.这些折线将在OpenGL场景中渲染.
我的意思是我需要将每个字母转换成一个或多个2D折线.
我如何在iOS(Objective-C或C++)中执行此操作
MyView *view=[[[MyView alloc] init] autorelease];
[view setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:view animated:YES];
Run Code Online (Sandbox Code Playgroud)
我在从一个视图控制器移动到另一个视图控制器时使用了翻转过渡.但我的要求是从左到右过渡.请提前帮助我解决这个问题.这是我的代码:
我有一个字符串,里面有'Optional(someVal)'.我想要一个正则表达式来查找和替换此关键字的所有匹配项并仅替换其中的内部值.我正在做的是......
query = "Insert Into table (Col, Col, Col, Col, Col, Col4, Col4, Col4, Col, AuditStatusId, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col, Col ) Values ('71E3F86A059A40F0B3F7614E08ACD2B9', 1, Optional(4), Optional(6), ' ', '', Optional(40799), 'NULL', NULL, 1, 1, NULL, NULL, NUll, 0, NULL, 1, '', NULL , NULL, 90.0, 100.0, 70.0, 89.99, 0.0, 69.99, 1, 1, '2015-01-15 14:09:34 +0000', 0 )"
Run Code Online (Sandbox Code Playgroud)
并使用正则表达式替换,
query = query.stringByReplacingOccurrencesOfString("(\\Optional(w+))", withString: "$1", options: …
Run Code Online (Sandbox Code Playgroud) 我正在寻找一个免费的iPhone编译器和模拟器来学习iPhone编程的基础知识.有吗?
ios ×10
iphone ×8
objective-c ×6
xcode ×4
arrays ×1
fonts ×1
nscoding ×1
nspredicate ×1
polyline ×1
regex ×1
rest ×1
restkit ×1
swift ×1
uitableview ×1
uiview ×1