xcode5.1.1下载地址的 summary在哪

ios - Xcode5.1.1 and Xcode6 beta7 iOS7.1 64-bit [Allocator] Allocator invalid, falling back to malloc - Stack Overflow
Learn, Share, Build
Each month, over 50 million developers come to Stack Overflow to learn, share their knowledge, and build their careers.
Join the world’s largest developer community.
Display name
Email address
By registering, you agree to the
[Allocator] Mapping failed %d
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
[Allocator] Allocator invalid, falling back to malloc
And my app crash!
1,24752751
For me, this is an issue with Crashlytics when running a 64-bit Simulator. Crashlytics is aware of the problem and say they're working on it.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled【原创】Newlife.XCode的常见功能使用(一)查询与数据初始化
本博客所有文章分类的总目录:/asxinyu/p/4288836.htmlNewlife XCode相关文章目录:/asxinyu/p/4329747.html1.前言声明:此Newlife.XCode非Mac的XCode,避免误会。1.群:16008002.博客论坛 :NewlifeX论坛(同时也是.Net Micro Framework/ApolloOS的交流论坛,帮助软件开发者使用C#快速进入嵌入式开发领域)
大石头博客Asxinyu博客  使用XCode已经3年了,谈不上精通,都是些基础功能使用,以前啃过很多次,了解过部分功能的实现细节,但终归是要应用的,当没有时间时,了解使用就可以了,所以现在更多关注业务相关的东西,操作,XCode已经很完善了。本文就对这几年应用过程的一些问题,以及很多人经常问起来的问题进行一个总结。今天就介绍2个主要的,比较常见的使用:表达式查询,实体数据初始化。  我们将在下一篇博客中重点介绍更加重量级的分库分表功能,以及通用配置辅助类的使用。敬请关注。  如果文章或者资源对您有用,请&推荐&和关注,接下来还有很多.NET平台关于机器学习、彩票分析平台和预测的文章和资源待发表。
本文原始地址:/asxinyu/p/4248281.html2.简洁优雅的查询  XCode对查询语法和灵活性是我见过的ORM中最优雅的,最简单体贴的。XCode由于支持多种数据库,并且效率很高的原因就是在这些数据库核心操作的背后有许多精巧的设计,其支持的查询就是XCode灵活强大的表现之一,每天写着重复的sql,调试,拼接参数,真的很累,那么看看XCode中的查询,真的是赏心悦目,是一种享受吧。首先对XCode的查询语法进行一个简单的总结和描述:1)XCode的查询很灵活,可以针对单个字段,也可以针对多个字段;例如: 1 var model1 = Find(_.Name, "中国");2 //下面2个结果是一样的,用的方法不一样3 var model2 = Find(new String[] { _.Name, _.OnceName }, new object[] {"中国","China" });4 var model3 = Find(_.Name == "中国" & _.OnceName == "China");5 //同理看一个FindAll的使用6 var modelList1 = FindAll(_.IsAsia, true);//只针对IsAsia字段7 //FindAll的最常见使用:5个参数的,第一个是条件表达式,第二个是排序字段(ComanyID),第三个是选择的字段,null代表选择所有8 //startIndex参数,代表起始行,默认都是从0开始,最后一个表示放回的数据行数,0代表所有行,可以只取前10。9 var modelList2 = FindAll(_.IsAsia == true & _.IsAuthority == true, _.ComanyID, null, 0, 0);2)XCode的查询是实体基类Entity&TEntity&封装好的静态方法,里面包含很多东西,建议熟练使用后的朋友,好好看一看,对理解XCode,更好的使用都有很大的好处。3) XCode中查询满足条件的记录数有专门的FindCount方法;其方法原型和FindAll类似。4)XCode有着非常完善的缓存体系,实体类是直接可以进行缓存设置和查询的,方法是FindAllWithCache;Meta.Cache.Entities中也有缓存数据,可以直接查询。例如:1 // 实体缓存2 Meta.Cache.Entities.FindAll(_.EventId, eventid);3 Meta.Cache.Entities.Find(_.Id, id);4 //单对象缓存5 return Meta.SingleCache[id];6 FindAllWithCache(_.EventName, "西甲");5)XCode的实体操作接口IEntityte中也有相对于的查询方法,使用与单个实体的Find和FindAll的使用基本相同。例如下面一段代码(2年前使用XCode迁移数据写的,非常好理解,也非常好的完成了迁移工作)。里面在对表进行处理的时候,就使用了IEntityOperate来操作,非常方便。其使用和原理可以看源码,和博客的其他文章。 1 /// &summary& 2 /// 拷贝数据库,只需要数据库连接字符串和源数据库即可 3 /// &/summary& 4 /// &param name="originConn"&源数据库连接字符串&/param& 5 /// &param name="desConn"&目的数据库连接字符串&/param& 6 /// &param name="perCount"&每次获取的记录数目,如果默认-1则会自动调用函数计算一个合理值&/param& 7 public static void CopyDataBase(string originConn,string desConn,int perCount = -1) 8 { 9
//思路:通过源数据库获取架构信息,然后反向工程,然后导出数据
DAL dal = DAL.Create(originConn);11
List&IDataTable& tableList = dal.T//获取源数据库的架构信息12
tableList.RemoveAll(t =& t.IsView);//过滤掉视图13
//首先拷贝数据库架构
DAL desDal = DAL.Create(desConn);//要在配置文件中启用数据库架构才行 15
desDal.Db.CreateMetaData().SetTables(tableList.ToArray());
//然后依次拷贝每个表中的数据17
foreach (var item in tableList)18
//首先根据表名称获取当前表的实体操作接口20
IEntityOperate Factory = dal.CreateOperate(item.Name);21
//获取数据,并更新到新的数据库,通过更改数据库连接来完成22
int allCount = Factory.FindCount ();23
if (perCount & 0) perCount = GetDataRowsPerConvert (allCount );24
int pages = (int)Math.Ceiling ((double)((double )allCount/(double )perCount));25
for (int i = 0; i & i++)26
Factory.ConnName = originC28
IEntityList modelList = Factory.FindAll(string.Empty, string.Empty, string.Empty, i * perCount, perCount);29
Factory.ConnName = desC30
modelList.Insert(true);31
Console.WriteLine("数据库{0} 数据转移完成!",item.Name );33
}34 }6)XCode中的查询表达式类型是WhereExession,实际中的SQL语句拼接的结果就是WhereExpression类型,而该类型的拼接支持&,|运算符的重载,可以直接将不同的条件组合在一起。拼接的字段名称为XX._.字段名,_的实体类型的用处也主要在这里,注意WhereExpression类型是可以隐式转换为String类型的。这也是为什么有人不解直接将WhereExpression类型放入FindAll第一个参数的原因,其实已经转换成String了。看看1个实际查询综合的例子(来源于大石头BBX项目中的代码): 1 /// &summary&获取有效的广告列表&/summary& 2 public static EntityList&Announcement& GetAvailableList() 3 { 4
//return FindAll(_.StartTime & DateTime.Now & _.EndTime & DateTime.Now, null, null, 0, 0); 5
var now = DateTime.N 6
return Search(null, null, now, now); 7 } 8
9 /// &summary&查询符合条件的公告&/summary&10 /// &param name="poster"&发布者&/param&11 /// &param name="title"&标题&/param&12 /// &param name="start"&开始时间&/param&13 /// &param name="end"&结束时间&/param&14 public static EntityList&Announcement& Search(String poster, String title, DateTime start, DateTime end)15 {16
if (Meta.Count &= 0) return new EntityList&Announcement&();17 18
// 公告的总数一般不多,可以使用实体缓存19
if (Meta.Count & 1000)20
var list = Meta.Cache.Entities.ToList().AsEnumerable();22 23
// 使用Linq从实体缓存里面过滤需要的数据24
if (!poster.IsNullOrWhiteSpace()) list = list.Where(e =& e.Poster.Contains(poster));25
if (!title.IsNullOrWhiteSpace()) list = list.Where(e =& e.Title.Contains(title));26
if (start & DateTime.MinValue) list = list.Where(e =& e.StartTime & start);27
if (end & DateTime.MinValue) list = list.Where(e =& e.EndTime & end);28 29
return new EntityList&Announcement&(list);30
var exp = new WhereExpression();33 34
// 使用条件表达式构建查询SQL语句35
if (!poster.IsNullOrWhiteSpace()) exp &= _.Poster.Contains(poster);36
if (!title.IsNullOrWhiteSpace()) exp &= _.Title.Contains(title);37
if (start & DateTime.MinValue) exp &= _.StartTime &38
if (end & DateTime.MinValue) exp &= _.EndTime &39 40
return FindAll(exp, null, null, 0, 0);41 } 至于_.这种情况,可能有人刚开始看不懂,其实看看XCoder生成的实体类型代码就知道了。这个类型是快速访问字段用的,非常方便。3.数据库的初始化,你难道还在手动或者用SQL?  这是一个很隐蔽的功能,应该有很多人刚入门的朋友没有注意到。这也是一个非常人性化的操作,在生成的&模型&里面,业务中有一个静态的构造函数InitData(),看看里面都有什么,这里举例是随便找的一个表,生成的结构相同,只不过字段不一样而已。虽然上面注释了,但很明显,这里是教大家怎么用的。在数据库反向工程执行的时候,首次连接数据库,就会执行这个方法,如果数据表是空的,那么程序就会自动执行指定的代码,进行数据插入。也就是说在你实际部署的时候,对于系统的初始化数据,根本不用去执行什么数据库SQL脚本,或者手动进行新建数据库和初始化的工作。  这一切都可以在程序里面迅速完成,而且非常简单,对于开发和测试来说,都非常简单,不需要你做任何管理。比如一些用户表和管理员表,可以初始化几个帐号;例如一些单位的部门信息,权限信息,都可以进行初始化。而且这一切都支持跨数据库,可以在几个数据库之间切换;而不是每一种数据库准备一套脚本。试想一下,开发机用sqlite开发,实际部署用,而程序只需要改变一个连接字符串就可以自动初始化这些数据。  看看我的一个例子,下面是一个 欧洲赔率公司的 信息表,系统用到的赔率公司的数量不多,只有20条左右。因为,只要是新的环境,或者实际部署,系统就会根据下面的逻辑进行初始化工作。FastInsert是一个快速插入当前记录的方法,自己手动写的。 1
/// &summary&首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法&/summary& 2
[EditorBrowsable(EditorBrowsableState.Never)] 3
protected override void InitData() 4
base.InitData(); 6
if (Meta.Count & 0) 7
if (XTrace.Debug) XTrace.WriteLine("开始初始化{0}赔率公司数据&&", typeof(CompanyInfo).Name); 8
#region 数据保存10
FastInsert("平均赔率", 1000, true, false, false, true);11
FastInsert("竞彩官方", 999, true, false, false, true);12
FastInsert("威廉希尔", 252, true, false, false, true);13
FastInsert("立博", 251, true, true, false, true);14
FastInsert("bet 365", 469, true, true, false, true);15
#region 其他公司16
FastInsert("Interwetten", 122, true, false, false, true);17
FastInsert("SNAI", 179, true, false, false, true);18
FastInsert("bwin", 65, true, false, false, true);19
FastInsert("伟德", 253, true, true, false, true);20
FastInsert("易胜博", 254, true, true, false, true);21
FastInsert("澳门", 247, true, true, false, true);22
FastInsert("Expekt", 92, true, false, false, true);23
FastInsert("Coral", 77, true, false, false, true);24
FastInsert("Iceland", 117, true, false, false, true);25
FastInsert("Oddset", 142, true, false, false, true);26
FastInsert("皇冠", 300, true, false, false, true);27
FastInsert("利记sbobet", 169, true, true, f
优质网站模板macos - Should I use Xcode 6.1 beta, or Xcode 6.0 GM? - Super User
Super User is a question and answer site for computer enthusiasts and power users. J it only takes a minute:
Here's how it works:
Anybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
I'm on OS X Yosemite (latest DP), and I can't make up my mind. The Apple developer website says that 6.0 GM is for Mavericks, and the 6.1 beta is for Yosemite. But 6.1 is still in beta, while the other is a GM version obviously. That makes me wonder... should I pick the one that matches my OS, or the one that is in a more stable version? I want to use it for actual app development, so I'm thinking the GM would be better since it's more reliable.
If you want to submit apps to the iOS App Store using Swift, I would go with Xcode 6 GM (as of this writing).
Apple's site is showing :
Download Xcode 6 GM seed and add new Swift code or frameworks to your existing apps, or create a brand new app using 100 percent Swift code. With the GM seed release of Xcode 6 and iOS 8, Swift 1.0 is now final, and you can build and submit your iOS apps written with Swift to the App Store today.
Swift for OS X is coming with OS X Yosemite later this fall. If you are using Swift to write Mac apps, you can download the Xcode 6.1 beta for Yosemite, which also includes the iOS 8 SDK GM seed.
I'm currently using XCode 6, installed from AppStore. It works fine on Mavericks. However, it has one serious problem with .sks particle files, which seems to be solved in 6.1 beta. The bottom line is this: if you have any existing particle files as .sks, XCode 6 will corrupt them, rendering them useless, and you will have to recreate them from scratch again. XCode 6 will keep crashing when you try to open those files, and the app build with XCode will also crash if you try to load particle emitters from those .sks files, as it will get confused between .sks being a scene or particle resource. More info on that here:
Use the Yosemite version, 6.1 beta as of this writing. Don't use the 6.0 GM on Yosemite. Particularly if you intend to use Swift.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Super User works best with JavaScript enabledCategories
by Matt Long
What inspired the Xcode LLDB Tutorial? Well, I tweeted this the other day:
A few people then responded over twitter asking that I would elaborate by writing a tutorial here on CIMGF. So here it is. Your wish is my command, The Xcode LLDB Tutorial
Apparent Debugger Design Goals
If you have ever done debugging without a debugger, then you know how great a debugger is–any debugger is better than none. The alternative is printing out messages in your code using printf back in the day of straight C, or NSLog these days if you aren’t yet comfortable with using a debugger.
Now, I won’t go into the history, but suffice it to say we used to use GDB, but LLDB is the current course and while the road has been a little bumpy during the transition, things are getting better and debugging is simpler and more powerful than ever. Apple has made it pretty clear that they are trying to give us the tools that enable us to leave the days of placing debug code in our apps behind. I think we’re there. You can now stop on a break point and start analyzing all of your code by using debugger commands and injecting actual Objective-C code that will get evaluated right while you’re running. You can even change the value of your variables on the fly or edit a break point and tell it to print out a variable and then continue running. It’s really quite powerful and your code can remain clean and un-tainted by debug code.
Just A Taste of the Xcode LLDB Tutorial
Let’s jump right in with a few basic LLDB commands. The most common commands you’ll use in the debugger are p (for print), for primitive types (booleans, integers, floats, etc.) and po (for print object) for Objective-C objects. When you type po and then then name of an object like the view of your view controller for example:
Objective-C
po [self view]
po [self view]
The debugger will print the description (found in NSObject and overridden by many classes) of that object. In this case it will print something like:
(UIView *) $1 = 0x &UITableView: 0x824c800; frame = (0 20; 768 1004); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = &NSArray: 0x74c3010&; layer = &CALayer: 0x74c2710&; contentOffset: {0, 0}&
So how do we get it to do that? Well, the first thing you need to do is set a break point. You do so by clicking in the line numbers on the line where you want to break. For the example above, I set a break point in viewDidLoad: like this:
Now run the app and wait for the debugger to break on the break point. Look at the bottom of the Xcode window and you’ll see the console where you enter in your LLDB commands.
A more useful command might be to get the number of subviews contained by our view controller’s view. Since the count of subviews is an integer, a primitive, we should use the p command instead of po. Like this:
Objective-C
p (int)[[[self view] subviews] count]
p (int)[[[self view] subviews] count]
This will print out:
(int) $2 = 2
Notice we type-casted our return type so the debugger knows what to do with it. Cool, isn’t it? Just wait, it gets better.
Parsing Twitter Feeds
(The code for this section is in the project called TwoDegrees. You can download it at .)
If you’re a seasoned Twitter API developer, you probably know something about the basic layout of the JSON you receive upon successful timeline request, but even you don’t have the whole thing memorized and will need a way from time to time to look up what the structure is like. Not to mention knowing those folks behind the Twitter API the layout may change from time to time. Wouldn’t it be nice to just spin off your request and then just analyze the response on the fly when you get it back. Watch this.
Here is some Twitter code implemented with iOS6’s Social framework.
Objective-C
- (void)downloadTimeline
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType
options:nil
completion:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *accounts = [accountStore accountsWithAccountType:accountType];
if ([accounts count] & 0) {
ACAccount *account = [accounts lastObject];
NSURL *url = [NSURL URLWithString:@"/1.1/statuses/home_timeline.json"];
NSDictionary *parameters = @{@"count" : @"200"};
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodGET
parameters:parameters];
[request setAccount:account];
[request performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse,
NSError *error) {
id response = [NSJSONSerialization
JSONObjectWithData:responseData
options:NSJSONReadingMutableLeaves
error:&error];
DLog(@"Response: %@", response);
if ([response count] & 0) {
dispatch_async(dispatch_get_main_queue(), ^{
// Do something on the main queue
DLog(@"Failed to get twitter account");
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
- (void)downloadTimeline{&&ACAccountStore *accountStore = [[ACAccountStore alloc] init];&&ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];&&&&[accountStore requestAccessToAccountsWithType:accountType&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&options:nil&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& completion:^(BOOL granted, NSError *error) {&&&& if (granted) {&&&&&& NSArray *accounts = [accountStore accountsWithAccountType:accountType];&&&&&& &&&&&& if ([accounts count] & 0) {&&&&&&&& ACAccount *account = [accounts lastObject];&&&&&&&& &&&&&&&& NSURL *url = [NSURL URLWithString:@"/1.1/statuses/home_timeline.json"];&&&&&&&& &&&&&&&& NSDictionary *parameters = @{@"count" : @"200"};&&&&&&&& &&&&&&&& SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& requestMethod:SLRequestMethodGET&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& URL:url&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&parameters:parameters];&&&&&&&& &&&&&&&& [request setAccount:account];&&&&&&&& &&&&&&&& [request performRequestWithHandler:^(NSData *responseData,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&NSHTTPURLResponse *urlResponse,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&NSError *error) {&&&&&&&&&& id response = [NSJSONSerialization&&&&&&&&&&&&&&&&&&&&&&&&&& JSONObjectWithData:responseData&&&&&&&&&&&&&&&&&&&&&&&&&& options:NSJSONReadingMutableLeaves&&&&&&&&&&&&&&&&&&&&&&&&&& error:&error];&&&&&&&&&& &&&&&&&&&& DLog(@"Response: %@", response);&&&&&&&&&&&&&&&&&&&&&&&&if ([response count] & 0) {&&&&&&&&&&&&&&dispatch_async(dispatch_get_main_queue(), ^{&&&&&&&&&&&&&&&&// Do something on the main queue&&&&&&&&&&&&&&});&&&&&&&&&&&&}&&&&&&&&&&}];&&&&&& }&&&& } else {&&&&&& DLog(@"Failed to get twitter account");&&&& }&& }];}
I placed a breakpoint on line 34 where the DLog is. Then I ran this in the console.
Objective-C
po [[response filteredArrayUsingPredicate:(NSPredicate*)[NSPredicate
predicateWithFormat:@"retweet_count & 0 and retweeted_status.entities.urls.@count & 0"]]
valueForKeyPath:@"retweeted_status"]
po [[response filteredArrayUsingPredicate:(NSPredicate*)[NSPredicate &&&&&&&&&&&&predicateWithFormat:@"retweet_count & 0 and retweeted_status.entities.urls.@count & 0"]]&&&&&&&&&&&&&&&&valueForKeyPath:@"retweeted_status"]
The response object is an array generated by Apple’s JSON parsing class, NSJSONSerialization using the raw data response we got back. This po command is effectively printing out any tweets that have been retweeted that contain at least one URL. So let’s think about that for a second:
“The philosophy behind this query is that if your tweeps retweeted something, it’s probably even more important or interesting to you than it would be otherwise and since it has a URL, the page it links to is probably something you’d be highly interested in reading.”
You can see in our debugger command everything is straight Objective-C code except for the po itself. Here are some important notes about that 1-liner (er, well I had to wrap it so you could see it without scrolling here, however, in my debugger it’s one line).
When passing a parameter to a method, you have to type-cast that parameter to whatever the method requires. So that’s why we have an (NSPredicate*) type-cast.
Our predicate contains two parts. The second one uses the @count parameter which evaluates a count of the URLs in the tweet and makes sure there is at least one.
If you’re not familiar with it, KVC, key-value coding, allows us to query our arrays for certain parameters like a count or a sum or we can access a particular property of all of the objects contained within our array. So back in our console, we can dig even deeper. Say that we want to show a list of all of the expanded_urls in those tweets that our tweeps retweeted. We can use some KVC to do it:
Objective-C
po [[response filteredArrayUsingPredicate:
(NSPredicate*)[NSPredicate predicateWithFormat:@"retweet_count & 0 and
retweeted_status.entities.urls.@count & 0"]]
valueForKeyPath:@"retweeted_status.entities.urls.expanded_url"]
po [[response filteredArrayUsingPredicate:&&&&&&&&&&&&&&&&(NSPredicate*)[NSPredicate predicateWithFormat:@"retweet_count & 0 and&&&&&&&&&&&&&&&&&&&&&&&& retweeted_status.entities.urls.@count & 0"]] &&&&&&&&&&&&&&&&&&&&&&&& valueForKeyPath:@"retweeted_status.entities.urls.expanded_url"]
Note: For those of you who are new to iOS development having come from C#, you’ll notice that KVC has some things in common with . They are different, but have some concepts in common that you may be familiar with.
See our call to valueForKeyPath: at the end of our array. Passing it the key path "retweeted_status.entities.urls.expanded_url" is accessing the expanded_url parameter for the list of urls in the entities collection inside each of the retweeted (retweet_count greater than zero) tweets. (Say what? Read it again. It’ll make more sense, I promise.)
Here is what the description for one of the retweeted tweet dictionaries (remember it’s a dictionary now that we parsed the raw JSON) looks like when printed in the console:
Objective-C
contributors = "&null&";
coordinates = "&null&";
"created_at" = "Wed Dec 12 19:32:40 +";
entities =
hashtags =
"display_url" = "/5958794/friend\U2026";
"expanded_url" = "/5958794/friends-dont-let-friends-drink-and-windows-8";
url = "http://t.co/13rMfmAm";
"user_mentions" =
"retweet_count" = 5;
retweeted = 0;
source = "&a href=\"/\" rel=\"nofollow\"&MetroTwit&/a&";
text = "Brilliant.
http://t.co/13rMfmAm";
// Truncated for brevity...
123456789101112131415161718192021222324252627
{&&&&contributors = "&null&";&&&&coordinates = "&null&";&&&&"created_at" = "Wed Dec 12 19:32:40 +";&&&&entities =&&&& {&&&&&&&&hashtags =&&&&&&&& (&&&&&&&&);&&&&&&&&urls =&&&&&&&& (&&&&&&&&&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&"display_url" = "/5958794/friend\U2026";&&&&&&&&&&&&&&&&"expanded_url" = "/5958794/friends-dont-let-friends-drink-and-windows-8";&&&&&&&&&&&&&&&&indices =&&&&&&&&&&&&&&&& (&&&&&&&&&&&&&&&&&&&&12,&&&&&&&&&&&&&&&&&&&&32&&&&&&&&&&&&&&&&);&&&&&&&&&&&&&&&&url = "http://t.co/13rMfmAm";&&&&&&&&&&&&}&&&&&&&&);&&&&&&&&"user_mentions" =&&&&&&&& (&&&&&&&&);&&&&};&&&&"retweet_count" = 5;&&&&retweeted = 0;&&&&source = "&a href=\"/\" rel=\"nofollow\"&MetroTwit&/a&";&&&&text = "Brilliant.&&http://t.co/13rMfmAm";&// Truncated for brevity...
If you realize our response object is actually an array containing a bunch of these dictionaries, you’ll understand that we are filtering that array with a predicate that is looking only for objects with a retweet_count greater than zero. That’s what tells us that it was retweeted. Then, with the valueForKeyPath: we are telling the resulting filtered array to give us all of the expanded_urls for all of those records. That’s pretty cool. Here’s what the output of that po command looks like:
Change The Value of Your Variables On The Fly
(The code for this section is in the project called BogusLogin. You can download it at . The code is really pointless/useless unless you set the breakpoints I describe below to see how they work. Breakpoints don’t get stored in the project, so you have to set them yourself.)
Let’s push a little farther. How often have you made some changes and restarted the debugger only to realize that the data you wanted is incorrect. Well, just fix it on the fly when you hit a break point using the expr command. Here’s how:
Say you’ve created a login method that authenticates with a server at the press of a login button (our sample code is just a dummy stub with no server connection, btw). If you have to enter those credentials in your app every time you run–tapping away on your device’s glass (and nearly knocking it over if you have a gorilla touch like me), it gets a little tedious and even time consuming. You could use a #ifdef DEBUG macro in your code and specify your debug credentials hard-coded, but why? Use a breakpoint instead. Here is some code with a breakpoint to demonstrate what I mean.
If you run your code and stop on that break point, you can just type:
Objective-C
expr username = @"username"
expr password = @"badpassword"
expr username = @"username"expr password = @"badpassword"
The console will respond back with:
Objective-C
(NSString *) $0 = 0x3d3504c4 @"username"
(NSString *) $1 = 0x1d18ef60 @"badpassword"
(NSString *) $0 = 0x3d3504c4 @"username"(NSString *) $1 = 0x1d18ef60 @"badpassword"
Now, if you let the next two log statements print to the console, you’ll see:
Objective-C
(0x1c59aae0) A line for the breakpoint
(0x1c59aae0) Username and Password after: username:badpassword
(0x1c59aae0) A line for the breakpoint(0x1c59aae0) Username and Password after: username:badpassword
But we can go even farther with this. You can edit your breakpoint and have it change the expression automatically and continue on without actually stopping. To do so, right click on the breakpoint and select “Edit Breakpoint…” (or Option-Cmd Click the breakpoint). Then give the breakpoint the settings you see here:
Notice that the checkbox labeled Automatically continue after evaluating is checked. This will ensure that your username and password get changed every time the breakpoint gets hit, but execution will just continue. So, if you have some testing credentials you use while working on your app, just set them in a breakpoint and you’ll never have to actually enter them into your credentials text fields on your login view and you’ll never have to set them in your source either. And the beautiful thing is you didn’t have to have any macros to determine if you were in DEBUG or not. When you ship your app, the breakpoints don’t exist so you will never run the risk of shipping conditional macro code with inverted logic. How awesome is that?
Just to drive the point home, go back into Xcode and click on the breakpoint we set again to disable it. It should now be a light blue color. If you run it again, you’ll see that the username and password no longer get changed.
Conditionals
Finally, one of the greatest powers of using breakpoints is that they allow for conditionals. Say you have a dataset coming back with tens of thousands of records. Say one of the records is corrupted and you know it’s ID, but you want to see what’s going on when that record is being processed/accessed. Place a breakpoint by clicking in the line number column on the line where your data is being processed–likely in some sort of loop. Or I sometimes find I need to see it when I’m trying to render a table cell in the table view delegate method tableView:cellForRowAtIndexPath:. I set the breakpoint there and as soon as that ID matches, I know that the related record is getting displayed. Execution stops and I can start analyzing the data using the other methods we’ve discussed in this post.
You set a condition in your breakpoint like this:
You can’t see the whole condition syntax in that screenshot, so here’s the actual line:
Objective-C
(BOOL)[(NSString*)[item valueForKey:@"ID"] isEqualToString:@"93306"]
(BOOL)[(NSString*)[item valueForKey:@"ID"] isEqualToString:@"93306"]
As with any commands you give the debugger that contains code you have to typecast everything. In this line we are saying that we only want the breakpoint to stop if our item’s ID field is equal to &#”. If you do place this breakpoint in tableView:cellForRowAtIndexPath:, you may find that your table view performance suffers, but keep in mind that you only need to keep that breakpoint enabled until you’ve figure out your issue. Then you can either disable it, or remove it.
Note: Sometimes I get overzealous and accidentally remove breakpoints that I may need again later. It’s probably best to just get in the habit of disabling them to keep from accidentally removing them. Obviously it’s not a big deal if they have no conditional logic, but if you’ve spent the time to add a condition, you’ll want to protect that breakpoint so you don’t have to enter it in again. Once you remove the breakpoint, you can’t undo. I suggest you train yourself to disable rather than remove unless you’re absolutely sure you won’t need that breakpoint again.
Formatting Strings
If we’re ever to get rid of NSLog, we need a way to get meaningful messages when we’re debugging through some other means. Fortunately, you can just format a string the way you normally would in code when adding a command to a breakpoint, except there’s one gotcha. You may be used to using NSString‘s stringWithFormat: however, this won’t work in the break point. You will instead need to use alloc/init like this:
Objective-C
po [[NSString alloc] initWithFormat:@"Item index is: %d", index]
po [[NSString alloc] initWithFormat:@"Item index is: %d", index]
I don’t know the exact reason at this time, however, when you try to use stringWithFormat:, you get the following error in the console window:
error: too many arguments to method call, expected 1, have 2
error: 1 errors parsing expression
error: too many arguments to method call, expected 1, have 2error: 1 errors parsing expression
Just use the alloc/init version and it will work fine.
I find this technique very handy and it allows me to avoid using NSLog at all. I realize that DLog is a good substitution for NSLog because it allows you to automatically remove NSLog when you ship a release build, but I’m really starting to like the options that LLDB gives you and you don’t have to add any additional pre-compiler conditional code to your PCH file. Cleaner/less code is always better in my opinion.
Conclusion
Obviously a lot of the LLDB functionality is built into Xcode–things like setting breakpoints by simply clicking on the line number where you want to set it, however, there is a lot of power with the commands that are available to you to execute while running in the debugger. This tutorial has only scratched the surface, but even with the few commands we’ve covered here, you can tell just how much power those few commands give you. If you have any other awesome pro tips for commands that have made your debugging life simpler in Xcode, please share them in the comments. Until next time.
Download the related source code here:
Great article!
I also found very useful to play a sound when hit a break point, is very useful when you just want to know that something happened without block the executions.
I want to share another tips: In the breakpoint navigator if you right click on a breakpoint you have the option to share it, I found it a bless to share breakpoint with my coworker. (it works well with git with .gitignore like this: )
[…] Matt Long goes into great detail on how to use the Xcode LLDB to solve bugs. If you work in Xcode, this is a must-read. […]
That’s a pretty cool trick setting up the login information in a breakpoint.
One simplification– when typecasting return types in LLDB, if the return type inherits from NSObject, you can just use “id”. It doesn’t actually matter if you get the class right, since LLDB isn’t consulting the header file anyway. So instead of typecasting to “(NSPredicate *)”, just use “(id)”.
& 2015, Cocoa Is My Girlfriend

我要回帖

更多关于 xcode5.1.1下载地址 的文章

 

随机推荐