nsobject

Find object by tag

橙三吉。 提交于 2019-12-24 09:48:44
问题 I have UITableView with UITextField s inside cells. Every UITextField has his own tag. How to access UITextField by tag? I was trying to google that answer, but looks like first 5 pages shows how to check tag of sender. 回答1: You can get the reference using viewWithTag and send message to the reference as you do normally. UITextField *tfObj=(UITextField*)[tblVuObj viewWithTag:1]; 回答2: A UITableView only holds visible cells. Therefor, you cannot access cells that are not visible. To iterate

Adding an image to a NSObject - Possible?

巧了我就是萌 提交于 2019-12-24 08:58:03
问题 I'm going to have objects, read from a .csv (Comma seperated file) which contains file names, later. Thats why i'm trying to do it like this. What I would like to accomplish is to have the button get the image from the filename in the csv. What i've tried so far: The Object: @interface question : NSObject { @private UIImage *imageName; } @property (nonatomic, retain)UIImage *imageName; (I have tried with NSString aswell as UIImage, neither works like I want them) ViewController: - (void

Custom Object empty after creation

浪子不回头ぞ 提交于 2019-12-24 01:24:21
问题 I have a custom object: Vendor that extends NSObject . I am initiating it like so: NSDictionary *vendorObj = [vendors objectAtIndex:i]; Vendor *vendor = [[Vendor alloc] initWithVendorInfo:vendorObj]; NSLog(@"VendorObj: %@", vendorObj); NSLog(@"Vendor: %@", vendor); Here is what the class looks like: @interface Vendor : NSObject @property (nonatomic, copy) NSString *name; @property (nonatomic, copy) NSString *description; - (id)initWithVendorInfo:(NSDictionary *)vendorDetails; @end

Trapping Objective C classes

∥☆過路亽.° 提交于 2019-12-23 16:34:10
问题 I'm trying to catch/override certain methods that get called within objects I have no access to. I would like to be able to subclass objects that are instantiated within system objects. For example, when I instantiate a UIWebView, it internally instantiates a UIScrollView. I'd like to be able to subclass that UIScrollView so I can modify certain aspects of its behavior by subclassing it. Is that possible? I have been trying to do this by using a category, @implementation UIScrollView

Creating an object that works with NSJSONSerialization dataWithJSONObject:options:error:

余生长醉 提交于 2019-12-23 12:07:00
问题 At the moment in order to use this function I'm "converting" my object into a dictionary. i.e. the property names become the keys and the property values become the values. Is there a way to properly do this so that an object will work with this function? i.e. similar to encodeWithCoder and initWithCoder for use with NSUserDefaults . I'd like to do ... NSData *data = [NSJSONSerialization dataWithJSONObject:myObject options:0 error:nil]; at the moment I do something like... NSData *data =

How Do I Initialize Two Instances of NSObject in the same ViewController - Swift

試著忘記壹切 提交于 2019-12-23 03:14:09
问题 Please bear with me. I'm new to programming and new to StackOverflow. I hope that my question will grant me a warm response for entering the programming community. An acquaintance, whose opinion I trust, told me to post this email to him on StackOverflow. What do I have to do to get two instances of NSObject to work in the same ViewController? I've initialized an NSObject subclass called SideBar and RightSideBar. They both draw from NSObject. The cells in the menu are called created by a

Need clarification on AnyObject in Swift

不想你离开。 提交于 2019-12-22 13:12:52
问题 Before I start, I have already read the Swift documentation. I am still trying to comprehend what AnyObject actually is. Is it a base class for all objects/classes in Swift, as NSObject is in Objective C? If I create an array of type [AnyObject] and populate it with Movie class instances, that would mean that AnyObject is a base class of the Movie class right? let someObjects: [AnyObject] = [ Movie(name: "2001: A Space Odyssey", director: "Stanley Kubrick"), Movie(name: "Moon", director:

How to create a Swift object in Objective-C?

邮差的信 提交于 2019-12-22 10:54:27
问题 If you define a swift class like this @objc class Cat { } In swift you can just do var c = Cat() But how do you make a Cat instance in Objective-C ? Subclassing NSObject works because you can then "alloc-init" but can we achieve this without subclassing an Objective-C class? 回答1: The most direct way is to subclass Cat from NSObject . If you can't do that, you will need to make a class method or a function that returns a Cat . @objc class Cat { class func create() -> Cat { return Cat() } }

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

我的梦境 提交于 2019-12-22 05:58:31
问题 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,

Storing NSObject using NSKeyedArchiver/ NSKeyedUnarchiver

Deadly 提交于 2019-12-22 01:11:42
问题 I have a class object like; BookEntity.h import <Cocoa/Cocoa.h> @interface BookEntity : NSObject<NSCoding> { NSString *name; NSString *surname; NSString *email; } @property(copy) NSString *name,*surname,*email; @end BookEntity.m #import "BookEntity.h" @implementation BookEntity @synthesize name,surname,email; - (void) encodeWithCoder: (NSCoder *)coder { [coder encodeObject: self forKey:@"appEntity"]; } - (id) initWithCoder: (NSCoder *)coder { if (self = [super init]) { self = [coder