Questions tagged [initwithcoder]

49 questions
1
vote
1 answer

set property to custom subview init through IB (for uitableviewcell templating)

I want to create a uitableview mixing different type of items to display. For each item, I want to display some generic infos (always same type and style) and some specifics (different type and style according to item type). = I need some kind of…
macbeb
  • 227
  • 2
  • 11
0
votes
1 answer

Need help implementing initWithCoder and NSUnarchiver with a singleton

I'm having trouble figuring out how to get the archiving to work in an iOS 5 app. I have a singleton SessionStore that I'd like to retrieve plist data if it exists upon initialization. SessionStore inherits from NSObject and has one ivar, an…
Nathan W
  • 15
  • 5
0
votes
1 answer

How do I efficiently manage screen size changes and redrawing with storyboards, initWithCoder, viewDidLoad and viewDidLayoutSubviews?

I am using storyboard layouts to set up view layout. I am supporting both iPhone and iPad layouts. When the view is created with initWithCoder:, it is initially created with the frame size of the device I was last looking at in Interface Builder. If…
0
votes
1 answer

Having a singleton use the value from initWithCoder instead of creating a new instance in Swift

I have a simple boolean variable in a function on which a set an observer to check when it changes: var userValid: Bool{ didSet{ let valid=userValid ? "valid" : "not valid" print("uservalid changed to \(valid)") } } I set it…
Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75
0
votes
0 answers

Swift UIViewController crashing w/ (fatal error: init(coder:) has not been implemented)

I have created a swift file MainViewController that declares/defines a class MainViewController. I've set my storyboard's only scene's custom class as this class. I have the following code: import Foundation class MainViewController :…
Alex Bollbach
  • 4,370
  • 9
  • 32
  • 80
0
votes
2 answers

Pass values between the controller

I use Storyboard create a view controller,but with the code instantiation,then pass the value to the controller. I know it will be called "initWithCoder:", but in the method the property is nil. I get the property values form somewhere?
RuiK
  • 3
  • 2
0
votes
3 answers

Trying to load a nib from interface builder

I have a UIView based class that has its own XIB. Lets call this class MyClass. So I have MyClass.xib, MyClass.h and MyClass.m. I have a UIView object on storyboard and I set that object's class to MyClass. I created a new UIView XIB and inside the…
Duck
  • 34,902
  • 47
  • 248
  • 470
0
votes
1 answer

What does initWithCoder initialize first-time values to?

I'm using NSCoding for a game I'm making to save stuff like a high score. My question is: What do these values get initially set as if they've never been saved before? Like in the first time running the app. It will decode the values, but there's no…
Jordy
  • 415
  • 5
  • 13
0
votes
2 answers

super initWIthCoder return parent type?

I think I'm missing something basic... I implemented a class with NSCoding and a child with NSCoding too, but when I call the initWithCoder of the child class , I get an InvalidArgument error. @interface Parent:…
George
  • 332
  • 1
  • 4
  • 16
0
votes
1 answer

Issue with initWithCoder: and NSKeyedUnarchiver

I'm currently attempting to add a game-saving feature to my app. The end goal is to get ~300 custom objects saved to a .plist file and extract them again later. I've made some headway, but I'm having some issues with initWithCoder: and I'm also…
rebello95
  • 8,486
  • 5
  • 44
  • 65
0
votes
1 answer

Serialize/Deserialize encoder/decoder not working

This is my first try at serializing data and I must not be doing something correctly because it's not working. Perhaps it's because the class I am trying to serialize is a delegate or perhaps it's because of the way I'm populating the data or…
Patricia
  • 5,019
  • 14
  • 72
  • 152
0
votes
2 answers

Set UIImageView frame in initWithCoder

I am trying to set the frame size of an UIImageView inside a subclass of UICollectionCell but it does not work. I use storyboard. In the code, everything works but the last line regarding the imageView. If i put the code in drawRect it works ok. -…
Sucrenoir
  • 2,994
  • 1
  • 27
  • 31
0
votes
1 answer

non-standard Storyboard view controller initialization (not -initWithCoder:)

Is there a way to use init methods other than -initWithCoder: for Storyboard view controllers? I already know that you can set properties on VCs inside -prepareForSegue:.
Morrowless
  • 6,856
  • 11
  • 51
  • 81
0
votes
1 answer

How to save an NSView without it's instance variables being overwritten by initWithFrame:?

A Cocoa newbie here. I was trying to encode an instance variable inside an NSView to save to a file. But whenever I encode it, it is being overwritten to (null) when the initWithFrame: is being called. Is there a way I can skip this behaviour and…
0
votes
1 answer

App stops working after adding messageUI.framework

App stops working after adding messageUI.framework I have a fully working App created and I want to add some new features. I added the messageUI.framework and it stoped working. If I delete the Framework it works again, but this is not the idea. The…
Octan
  • 348
  • 4
  • 19