Initializers are called to create a new instance of a particular type. In its simplest form, an initializer is like an instance method with no parameters
Questions tagged [initializer]
684 questions
0
votes
2 answers
Initializing constant from constant lookup table
I have a constant lookup table
static const uint32_t lut [] = {0, 20, 100, 350, 560};
I have a struct
typedef struct {
uint32_t value;
const char * name;
} strct_t;
And I would like to create global constant instance of that struct
const…

j123b567
- 3,110
- 1
- 23
- 32
0
votes
0 answers
swift 3 override init does not override / cannot find overloads
I can't seem to extend a class from cocoapod ra1028/Former in my application with the right initializers from the parent class. Why is this?
See below situation divided into the code from the pod and my application code (ExtendedFormLabelHeaderView…

Max
- 21
- 4
0
votes
1 answer
UnsafeMutablePointer usage in Swift 3
I am using the following extension for UIBezierPath:
extension UIBezierPath {
var elements: [PathElement] {
var pathElements = [PathElement]()
withUnsafeMutablePointer(&pathElements) { elementsPointer in
…

Hasaa2 Khidala
- 161
- 1
- 3
0
votes
3 answers
Error in initializing structure variables
Okay, so this isn't actually the code I was working on. This is an oversimplified code extract that produces the exact same error. Thus, I thought if I could learn why I am getting errors with the simplified code, then I could apply it to my actual…

rickylance
- 67
- 9
0
votes
1 answer
Calling a Spring @Service on web application initialization
I have a web application that needs some static variables initialization as soon as I thrown the .war in the Tomcat webapp folder. This initialization needs to call a @Service to retrieve the initial set up.
I realized that the @Autowire injection…

Jaabax
- 155
- 2
- 8
0
votes
1 answer
Circle Layer error with super.init - Swift
This is going to be a really basic question.
I am working through this answer:
Animate drawing of a circle
But no matter how I format it I get an error. I can see from the error that I have not initialized circle and I am sure it is just a…

Nicholas Muir
- 2,897
- 8
- 39
- 89
0
votes
2 answers
Getting initializer error on ViewController
I get the error: "Class 'ViewController' has no initializer". I have narrowed down the problem to this function that is being called. Does anyone see the problem?
let locationManager1: CLLocationManager // your location manager
func…

Steve
- 1,121
- 1
- 12
- 32
0
votes
1 answer
EF6 seeding via initializer and one-to-many ICollection
I am following the EF6 code first walk-through, and have tried to adapt it slightly to suit my own project, but I have run into a problem when seeding the database with the initializer.
I have created 2 classes:
A property mode:
namespace…

Gavin5511
- 791
- 5
- 31
0
votes
1 answer
JAVA After adding a seccond button and its actionListener, actions get executed twice
After adding a listener to a second button, the first created button executes twice the same action:
public class ControladorTablaMaterial implements ActionListener {
private VistaTablaMaterial vistaTablaMaterial;
private JPanel jContentPane…

DavidVV
- 225
- 1
- 4
- 12
0
votes
1 answer
Is it possible to create a ruby gem that when added to a rails project simply appends code to its initializers?
I've got some helper code (monkey patches) I tend to carry around from rails project to rails project via simply copying files or pasting code into the initializers folder.
I think a clean way to deploy different categories of my initalizer code…

boulder_ruby
- 38,457
- 9
- 79
- 100
0
votes
1 answer
java member method initializer pattern to what extent this design is correct bug safe and suggestions to improve it
to avoid the overridable method call in constructor dilemma this approache delegate the variables initialization and calls to overridable methods to a member method that return reference to the instance its self and exception to be thrown if trying…

Ahmed Mazher
- 323
- 3
- 7
0
votes
3 answers
instance of a failable init method
This is my code:
struct Book{
let title: String
let author: String
let price: String?
let pubDate: String?
init?(title: String, author: String, price: String, pubDate: String){
guard let title = title, let author = author else…

Jake
- 53
- 1
- 3
- 8
0
votes
2 answers
Why I cannot place a designated initliazer in to a extension of a class?
It works fine when I put a designated initializer into the structure's extension (please see the example as follow)
struct BaseOne {
var a = 12
var b = 22
}
extension BaseOne {
init(a: Int){
self.a = a
self.b = 231
…

SLN
- 4,772
- 2
- 38
- 79
0
votes
2 answers
Changing the initial value of a var in another module
I am using this module to display an image:
https://github.com/huynguyencong/ImageScrollView/blob/master/Sources/ImageScrollView.swift
I have added it to my project using CocoaPods and I want to change the value of the var "maxScaleFromMinScale". I…

Alex
- 731
- 1
- 11
- 24
0
votes
2 answers
Property initialization does not call set for List
I've got a scenario I discovered when checking code coverage on a class's properties. When the property is of type List< T >, and an initializer is used, the set method doesn't appear to be called. This isn't true of other types, like strings and…

Smack Jack
- 257
- 4
- 16