天道酬勤,学无止境

objective-c

UILabel doesn't change height on setFrame

I'm trying to change the height of a UILabel depending on how much text is in the label. I can calculate the size required for the label but when I try to set the UILabel frame it just doesn't change. Below is my code. Even if I replace size.height in the last line to something like 500 the size of the UILabel frame doesn't change - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *simpleTableIdentifier = @"GameItemCell"; GameItemCell *cell = (GameItemCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]

2021-06-15 18:10:22    分类:问答    iphone   ios   objective-c   cocoa-touch

How to use UITableViewCell with UITableViewCellStyle with cell reuse correctly?

I want to use UITableViewCellStyle.Subtitle style for the default table cells. I found an answer in an SO answer like this: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { var cell:UITableViewCell? = tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell? if (cell != nil) { cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "cell") } } With the code above, I can successfully use the Subtitle cell style. However, I start to think something might be wrong? Why create a new cell when cell != nil

2021-06-15 18:05:46    分类:问答    ios   objective-c   swift   uitableview

How can I stop HIToolbox from catching my exceptions?

This question follows on from my other question on why my app isn't being brought down by exceptions. The Problem When an exception is thrown on the main thread via an Action, the app still doesn't crash. As per Dave's answer to my original question, I've implemented the reportException category on NSApplication and set the uncaught exception handler. Code I've got the following in my app delegate, which I've hooked up to a button in my UI to test. -(IBAction)crashOnMainThread:(id)sender { [self performSelectorOnMainThread:@selector(crash) withObject:nil waitUntilDone:YES]; } -(void)crash { //

2021-06-15 17:59:52    分类:问答    objective-c   cocoa   exception-handling   macos-carbon

Debugging an iPhone crash report

How do I debug the following crash report? A user installs the App from the App Store but the App crashes when loaded. I cannot re-produce the crash myself. I went to my crash reports on my own iPad and found a similar one, but again, cannot re-produce it. The problem is for the user that it prevents the App from loading (whereas, the crash I found myself just crashed the App, but it works fine when restarted). Is there anybody who can point me in the way to debug the below? SysInfoCrashReporterKey 31136b81228e5ddf6387c3aed3543d3580bcca2c bug_type 109 description Incident Identifier: F112DB19

2021-06-15 17:57:16    分类:问答    objective-c   cocoa-touch   ipad   crash-reports

Adding components to path - Objective C

I have a url say : www.gmail.com/index.php. I also have three different strings say aa, bb and cc. I want to append the three separate strings to the url in order to get a combined url in Objective C i.e I want www.gmail.com/index.php/aa/bb/cc . Can someone help me out ?? I am new to objective C. Thanks.

2021-06-15 17:39:44    分类:问答    iphone   objective-c   ios   xcode   ipad

Sorting Number using NSSortDescriptor

I got stuck in another problem again but after a long time. This time I have database (Core Data), having an attribute of numbers which contains integer numbers like 213879,123,4,345,56567 and so. I need to fetch data in ascending number order similar to like alphabetically order. I am doing this in way given below, fetchRequest.sortDescriptors=[NSArray arrayWithObject: [NSSortDescriptor sortDescriptorWithKey:@"numbers" ascending:YES selector:@selector(compare:)]]; but unfortunately it compares only the 1st digit of every number, mean if there are 2 numbers like 123 and 321, it will compare 1

2021-06-15 17:34:08    分类:问答    objective-c   core-data   ios6   nsnumber   nssortdescriptor

Change a value within a NSMutableArray

I have a NSMutableArray that is loaded with values. Later in the application, I need to change the values of one of the elements in the array. How do I accomplish this? thanks tony

2021-06-15 17:24:15    分类:问答    objective-c   cocoa   nsmutablearray

Taming XCode's auto-complete options

I am fairly new to XCode and the Objective-C language. When I am instantiating a class, for example an NSMutableArray, XCode will provide a whole lot of auto-complete options. Even for an empty class which simply extends an NSObject has many options, most of which seem completely useless. What is the reason for having so many auto-complete options, or can they be "tamed" in the preferences? NOTE: This is unintentionally a duplicate.

2021-06-15 16:58:08    分类:问答    objective-c   xcode   autocomplete

Restkit to-many relationship append to set instead of setting a new set

I have a iOS Restkit related question. I have a parent-child relationship data coming from a remote server and map those object to a NSManagedObject object with Restkit. The problem that I am currently having is every request to the server always wipe out the "child" relationship and replace it with the new data coming from the server. Is there a way to avoid those and append the new child instead? For example: I have a classic Category --> Products relationship. {"categories": [ { "cat_id": "1", "cat_title": "category 1", "cat_tag": 1, "product": [ { "prod_id": "1", "prod_name": "product 1",

2021-06-15 16:55:28    分类:问答    objective-c   ios   restkit   object-object-mapping

Is NSObject class a part of the Objective-C runtime library today (instead of being a Foundation component)?

Looking at the Mac OS X 10.8's version of the Objective-C runtime library source code, I noticed that it's got a NSObject.mm file. As its name suggests, it's got the NSObject class implementation, as well as built-in autorelease pool and retain count implementations. However, versions of the ObjC runtime library prior to Mountain Lion's one didn't implement the NSObject class (they didn't have a NSObject.mm file, as you can see at the Mac OS X 10.7's Objective-C runtime library source code, for example). So does this really mean that the NSObject class is now part of the Objective-C runtime

2021-06-15 16:52:55    分类:问答    objective-c   cocoa   foundation   nsobject   objective-c-runtime