cgfloat Questions
3
Solved
This is my current way of converting a CGFloat to String in Swift:
let x:Float = Float(CGFloat)
let y:Int = Int(x)
let z:String = String(y)
Is there a more efficient way of doing this?
5
Solved
I am writing a function in Swift to detect which hexagon I am clicking on. But I ran into a peculiar error message stating that I cannot add two CGFloats. Whatever I did, e.g. changing let to var, ...
7
Solved
How can I round up a CGFloat in Swift?
I've tried ceil(CDouble(myCGFloat)) but that only works on iPad Air & iPhone 5S.
When running on another simulated device I get an error saying 'NSNumber...
4
Solved
I'm trying to draw a simple circle when I get to the following line I get the error "Double is Not Convertable to CGFloat under the startAngle = 0.0
path.addArcWithCenter(center, radius: radiu...
4
var posinonY:Float = Float(y) + Float(pipeDown.size.height) + Float(verticalPipeGap)
pipeDown.position = CGPointMake(0.0, Float(posinonY))
I get this error:
"NSNumber' is not a subtype of 'C...
5
Solved
2
Solved
On using this function in swift and i am getting compiler error.
Function is:
class func imageWithImage (imageToResize : UIImage, scaledToSize newSize : CGSize) {
return imageToResize;
}
and th...
Raspings asked 30/7, 2014 at 8:18
11
Solved
In Swift, I'm trying to get a random float between 0 and 1 but I can't seem to get the type conversions to work.
func randomCGFloat() -> CGFloat {
return CGFloat(arc4random()) / UINT32_MAX
}
...
Practically asked 31/7, 2014 at 3:20
2
Solved
As we all know, CGFloat (which is ubiquitous in CoreGraphics, UIKit etc)
can be a 32-bit or 64-bit floating point number, depending on the
processor architecture.
In C, CGFloat it is a typealias
to...
3
Solved
Coding in Swift and get the above error...
Is the message masking something else OR can you really not add two CGFloat operands? If not, why (on earth) not?
EDIT
There is nothing special in the ...
0
FIXED IN SWIFT 4.2
Details
Xcode 9.2, Swift 4
Code
extension BinaryFloatingPoint {
func toInt() -> Int {
// Eror if remove this block (I do not know why)
// if let value = self as? CG...
8
Solved
I need to create a CGSize to compute text height of an arbitrary text with arbitrary length. UIKit has this nice method -sizeWithFont:constrainedToSize: and my text is only constrained in width, bu...
Poirier asked 8/6, 2011 at 20:58
3
Solved
CGSize(width: 360, height: 480) and CGSizeMake(360, 480) seem to have the same effect. Is one preferred to the other? What is the difference?
6
Solved
I made this method
+ (CGFloat) round: (CGFloat)f {
int a = f;
CGFloat b = a;
return b;
}
It works as expected but it only rounds down. And if it's a negative number it still rounds down.
Thi...
Phago asked 19/4, 2010 at 11:57
1
Solved
I'm new to Swift and just saw this code used to generate a random angle degree in a tutorial.
func random() ->CGFloat{
return CGFloat(Float(arc4random()) / 0xFFFFFFFF)
}
func random(#min: CGFl...
3
I have an app with about 30 active users and 500+ registered users and this issue is only happening with one person who is on 9.2 using an iPhone 6.
I can see from crash reports she's had over 60 ...
Tsarina asked 15/12, 2015 at 9:20
1
Solved
I was trying to do something like this
var myCGFloat: CGFloat = 3.001
ceilf(myCGFloat)
but ceilf only takes Float values. While searching around there were lots of different answers about doing ...
4
Solved
It might be a simple solution but I can not fix it.
I am dividing 2 integers :
finishedGameFinalScore = [score integerValue];
CGFloat interval = 2/finishedGameFinalScore;
NSLog(@"interval = %f",i...
Unspoken asked 15/8, 2012 at 12:28
1
Solved
I'm having an error when compiling a project in Xcode, it says:
Expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
he...
Whitt asked 19/11, 2015 at 3:8
2
Solved
I have a UILabel called optionsDisplayerBrushSizeLabel who's text property I want to set to a CGFloat: brushSizeVal. I understand that the text property needs to be a string but I don't know how to...
Derickderide asked 30/12, 2009 at 4:46
2
Solved
TLDR: How do I call standard floating point code in a way that compiles both 32 and 64 bit CGFloats without warnings?
CGFloat is defined as either double or float, depending on the compiler sett...
Phira asked 8/10, 2011 at 5:8
4
Solved
Trying to do arithmetic in a function that returns `CGFloat, I get an error:
Couldn't find overload for '/' that accepts supplied arguments
func kDCControlDegreesToRadians(x : CGFloat) -> C...
Cyanocobalamin asked 9/6, 2014 at 10:17
2
Solved
Here my code. I am passing two values into CGRectMake(..) and getting and error.
let width = CMVideoFormatDescriptionGetDimensions(device.activeFormat.formatDescription as CMVideoFormatDescription...
3
Solved
I need to store a value as a Float, but the source data is a CGFloat:
let myFloat : Float = myRect.origin.x
but this results in the compiler error: 'NSNumber' is not of subtype 'Float'
So if I ...
1
Solved
I have more problems within my app. My errors is as the title says:
Swift Compiler Error.
Error1:
'CGFloat' is not Convertible to 'Float'
Code for the 1st and 2nd error:
self.setPositionRelat...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.