Click here to Skip to main content
15,033,917 members
Home / Discussions / Objective-C and Swift
   

Objective-C and Swift

 
QuestionHow to get the sensor data Pin
Member 1302743027-Feb-17 14:56
MemberMember 1302743027-Feb-17 14:56 
AnswerRe: How to get the sensor data Pin
Richard MacCutchan27-Feb-17 21:22
mveRichard MacCutchan27-Feb-17 21:22 
Questionimage from custom NSView , image quality is very bad. Pin
Le@rner16-Jan-17 18:50
MemberLe@rner16-Jan-17 18:50 
AnswerRe: image from custom NSView , image quality is very bad. Pin
Surya_Narayan10-Apr-17 23:31
professionalSurya_Narayan10-Apr-17 23:31 
GeneralRe: image from custom NSView , image quality is very bad. Pin
Le@rner11-Apr-17 22:17
MemberLe@rner11-Apr-17 22:17 
QuestionSimultaneous Microphone Access on iPhone Pin
Member 123773388-Mar-16 0:35
MemberMember 123773388-Mar-16 0:35 
AnswerMessage Closed Pin
22-Nov-16 22:38
MemberMember 1286606322-Nov-16 22:38 
QuestionObjective C first program from the book, warning messages Pin
Alla__10-Nov-15 1:44
MemberAlla__10-Nov-15 1:44 
Hello!

I am new to this forum, and new to programming, although I have already reached chapter 18
of Programming in C textbook.

Please, take a look at the program I typed in from the book, and warning messages I receive.
I would be grateful for explanation on what I am doing wrong. I work on Mac OS 10.7.5, Xcode 4.6.3,
Terminal 2.2.3.
1) I created a file with the command:
touch prog18-2.m// Program ot work with fractions - Objective-C version

2) Program
#import <stdio.h>
#import <objc object.h="">

//------ @interface section ---------

@interface Fraction: Object
{
int numerator;
int denominator;
}
-(void) set_numerator: (int) n;
-(void) set_denominator: (int) d;
-(void) print;

@end

// ----- @implementation section -------

@implementation Fraction;

// getters
-(int) numerator
{
return numerator;
}

-(int) denominator
{
return denominator;
}

//setters
-(void) set_numerator: (int) num
{
numerator = num;
}

-(void) set_denominator: (int) denom
{
denominator = denom;
}

//other
-(void) print
{
printf("The value of the fraction is %i/%i\n", numerator, denominator);
}

@end

//-------- program section -----------

int main(void)
{
Fraction* my_fract;
my_fract = [Fraction new];

[my_fract set_numerator: 1];
[my_fract set_denominator: 3];

printf("The numerator is %i, and teh denominator is %i\n", [my_fract numerator], [my_fract denominator]);
[my_fract print];

[my_fract free]; //frees the memory that was used by Fraction object

return 0;
}

3) I compiled it with:
gcc -framework Foundation prog18-2.m -o prog18-2

4) Terminal generated the following:
prog18-2.m: In function ‘main’:
prog18-2.m:58: warning: ‘Fraction’ may not respond to ‘+new’
prog18-2.m:58: warning: (Messages without a matching method signature
prog18-2.m:58: warning: will be assumed to return ‘id’ and accept
prog18-2.m:58: warning: ‘...’ as arguments.)
prog18-2.m:71: warning: ‘Fraction’ may not respond to ‘-free’

Thank you!
AnswerRe: Objective C first program from the book, warning messages Pin
BharathReddy V12-Jan-16 2:04
MemberBharathReddy V12-Jan-16 2:04 
QuestionLinker command failed with exit code 1 (use -v to see invocation) in xcode 5.1.1 Pin
Member 1198376314-Sep-15 10:17
MemberMember 1198376314-Sep-15 10:17 
QuestionImagePickerController image size Pin
liel333-Aug-15 11:30
Memberliel333-Aug-15 11:30 
AnswerRe: ImagePickerController image size Pin
biji cabe18-Dec-16 22:25
Memberbiji cabe18-Dec-16 22:25 
QuestioniOS XMPP received message in coversation screen Pin
Member 1176696715-Jun-15 2:37
MemberMember 1176696715-Jun-15 2:37 
SuggestionRe: iOS XMPP received message in coversation screen Pin
Richard MacCutchan15-Jun-15 4:19
mveRichard MacCutchan15-Jun-15 4:19 
GeneralRe: iOS XMPP received message in coversation screen Pin
Member 1176696715-Jun-15 20:42
MemberMember 1176696715-Jun-15 20:42 
AnswerRe: iOS XMPP received message in coversation screen Pin
Dennis E White17-Jun-15 5:54
professionalDennis E White17-Jun-15 5:54 
Questionmake a system monitor using obj c. Pin
Member 116779679-May-15 13:00
MemberMember 116779679-May-15 13:00 
AnswerRe: make a system monitor using obj c. Pin
Richard MacCutchan9-May-15 21:10
mveRichard MacCutchan9-May-15 21:10 
GeneralRe: make a system monitor using obj c. Pin
Dennis E White15-May-15 5:25
professionalDennis E White15-May-15 5:25 
GeneralRe: make a system monitor using obj c. Pin
Richard MacCutchan15-May-15 5:41
mveRichard MacCutchan15-May-15 5:41 
GeneralRe: make a system monitor using obj c. Pin
Dennis E White15-May-15 6:04
professionalDennis E White15-May-15 6:04 
GeneralApp that converts human years to dog years Pin
Member 115920608-Apr-15 15:44
MemberMember 115920608-Apr-15 15:44 
GeneralRe: App that converts human years to dog years Pin
Dennis E White11-Apr-15 9:34
professionalDennis E White11-Apr-15 9:34 
GeneralRe: App that converts human years to dog years Pin
Richard MacCutchan11-Apr-15 22:05
mveRichard MacCutchan11-Apr-15 22:05 
GeneralRe: App that converts human years to dog years Pin
Dennis E White13-Apr-15 10:09
professionalDennis E White13-Apr-15 10:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.