Questions tagged [associated-object]
60 questions
0
votes
1 answer
What is the benefit of using associated objects vs static object defined in the category implementation file?
The problem is I don't see the benefit of using associated objects vs static objects defined in the category implementation file with getter/setter methods.
I was thinking about defining the getters and setters in the header file of the category.…

denis631
- 1,765
- 3
- 17
- 38
0
votes
1 answer
Creating a CGRect as an Associated Object?
I'm attempting to create a CGRect property for my UIButton's as an associated object, so that I don't have to subclass UIButton just for this.
Basically I'm adding a property titled, tapArea, and I'm having trouble creating it. This is what I have…

KingPolygon
- 4,753
- 7
- 43
- 72
0
votes
2 answers
Parse: How to add object to the user, who is not not the current user
i have created my app, in which I have created several users. The challenge is, I need to construct the app in a way that, while I am logged in as a user (say User A), I can add input an object into another user (say User B). So, while am logged in…

Ntungiyehe Luyagaza
- 23
- 6
0
votes
1 answer
Rails: How to not create new join models for newly associated objects
I'm working in Ruby on Rails 4.1.6. I have two associated models (Post and User) through another one (Comment).
User model:
class User < ActiveRecord::Base
has_many :comments, dependent: :destroy
has_many :posts, through: :comments
end
Post…

Damian
- 3
- 1
- 3
0
votes
1 answer
Xcode CodeSense error - Property not found on object of type, but project compiles
I have this in my .pch file:
#import "UIViewController+Loader.h"
The implementation for the category looks like this:
static char kUIViewControllerBaseViewKey;
@implementation UIViewController (Loader)
- (void)setLoader:(LoaderView *)loaderView…

soleil
- 12,133
- 33
- 112
- 183
0
votes
1 answer
Rails - Find with no associated records
I want to select one user and add to it associated records such as child for this example.
But only the child with a specific place_id.
This code works, but when the user doesn't have any child entry I got an error.
@user =…

user2037696
- 1,055
- 3
- 16
- 33
0
votes
1 answer
iOS: Grabbing An object's bounds for -colorWithPatternImage: in UIColor Category?
Is there a way to grab an object's bounds who's backgroundColor is being set in a UIColor category?
For example, I'm trying to apply a UIColor from an image, but I want it to be stretched out accordingly. Would associated references do the job? Or…

KingPolygon
- 4,753
- 7
- 43
- 72
0
votes
1 answer
objc_getAssociatedObject suddenly starts returning nil
I have a category for the NSURLConnection and I use associated objects to extend the class to keep a reference to a custom class of mine so I can get later in other context when delegate and forward the call to the real target later. This way I can…

George Taskos
- 8,324
- 18
- 82
- 147
0
votes
1 answer
Ordering by count of associated model Rails 4
I have two models:
jacket.rb:
has_many :button
belongs_to :store
button.rb:
belongs_to :jacket
In my store controller, I want to be able to do @store.jackets.order(buttons: :desc), but I cannot do this because it is not a db column. How would…

delisdeli
- 839
- 9
- 20
0
votes
2 answers
Sunspot Profile, Match search associated model attribute results in
Want to easy search all associated model attributes
Asked before still problems with this:
Profile model
has_one :match
searchable do
integer :id
string :country
string :state
string :city
end
Match model…

Rubytastic
- 15,001
- 18
- 87
- 175
0
votes
2 answers
Entity Framework: check if object exists and check if it has an associated object
In a many-to-many relationship between File and Category I want to check if a file exists and if so, if it has any categories (because there's a chance it may not have any) :
public bool existsInDBAndHasCategories(string path)
{
…

Ilian Vasilev Kulishev
- 605
- 2
- 9
- 14
0
votes
1 answer
Adding ivars to a Category with objc_setAssociatedObject
I'm planning to add to iVars to a category with objc_setAssociatedObject(). However, I'm unsure on when to call objc_removeAssociatedObjects() to get rid of them.
Is there a way the category can know when the object using it has been de-allocated ?

cfischer
- 24,452
- 37
- 131
- 214
0
votes
2 answers
Determining the actual Runtime Type of an AssociatedObject
I have a behavior which I would like to attach to multiple controls and based on their type, I would like to write the logic and for this I need to determine the type of the associated object at runtime and I was wondering how can I do that
class…

Harsha
- 103
- 1
- 2
- 13
0
votes
1 answer
Associate Pre-existing Record with Pre-Existing Parent (2 parent objects)
I have several models in nested attributes that I'm working with.
I have "teams" (has many constests), and "contests" (belongs to Team). But I also want contests to reference "categories" as a child object (a contest can only have one category, and…

T-bonemcgee
- 23
- 6
0
votes
2 answers
Does a setter also "reset" an associated object?
While getting into a nice long argument over memory locations vs pointers vs associated objects, we stumbled across a little bit of a headache: While setters may set the memory address of passed objects equal to each other, does said passed object,…

CodaFi
- 43,043
- 8
- 107
- 153