Is this a good start for an Objective-C program written without a framework? The Next CEO of Stack OverflowHandling SIGINT signal for a server programIs this proper code for removing a CCSprite under certain conditions?Objective-C class for placing UI elements based on screen sizeHow can I remove this for-loop in this competitive FizzBuzz code?SQLConnect - A library for connecting Objective-C/Swift applications to Microsoft SQL ServerUsing a TSV text file and map for a Q&A program“Silly program” for moving the mouse and doing other thingsQuicksort for Objective-CInterview Coding Challeng for iOS Part 1 - the Static Objective-C LibraryInterview coding challenge for iOS Part 2 - the application in Objective-C and Swift
"Eavesdropping" vs "Listen in on"
Reference request: Grassmannian and Plucker coordinates in type B, C, D
Purpose of level-shifter with same in and out voltages
Lucky Feat: How can "more than one creature spend a luck point to influence the outcome of a roll"?
What does "shotgun unity" refer to here in this sentence?
Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?
How to avoid supervisors with prejudiced views?
Is dried pee considered dirt?
what's the use of '% to gdp' type of variables?
Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?
Is there a way to save my career from absolute disaster?
Spaces in which all closed sets are regular closed
Reshaping json / reparing json inside shell script (remove trailing comma)
How to Implement Deterministic Encryption Safely in .NET
Expressing the idea of having a very busy time
Can this note be analyzed as a non-chord tone?
Would a completely good Muggle be able to use a wand?
Is it convenient to ask the journal's editor for two additional days to complete a review?
Can someone explain this formula for calculating Manhattan distance?
Why don't programming languages automatically manage the synchronous/asynchronous problem?
Players Circumventing the limitations of Wish
I dug holes for my pergola too wide
What day is it again?
Why is information "lost" when it got into a black hole?
Is this a good start for an Objective-C program written without a framework?
The Next CEO of Stack OverflowHandling SIGINT signal for a server programIs this proper code for removing a CCSprite under certain conditions?Objective-C class for placing UI elements based on screen sizeHow can I remove this for-loop in this competitive FizzBuzz code?SQLConnect - A library for connecting Objective-C/Swift applications to Microsoft SQL ServerUsing a TSV text file and map for a Q&A program“Silly program” for moving the mouse and doing other thingsQuicksort for Objective-CInterview Coding Challeng for iOS Part 1 - the Static Objective-C LibraryInterview coding challenge for iOS Part 2 - the application in Objective-C and Swift
$begingroup$
I have been developing a cross-platform game based on open C libraries (mainly glfw) with a direct focus on Windows development. The beginning of my programming career taught me familiarity in Objective-C, however I've been using pure C for the past few years in embedded applications.
Now that I'm trying to return to proper desktop program development, I'm wondering if it's a good idea to transfer my Objective-C skills to Windows in order to tidy up my C code. My current way of programming is creating a struct for data that I need and then creating functions around those structs: struct Point int x, int y; and then float Point_calculateDistance(struct Point *obj1, struct Point *obj2). This approach to me seemed very redundant and too object-oriented to write all in C. It would make more sense to me to write an Objective-C class to do this where everything can be more encapsulated.
I prefer not to use any framework for my code to increase the portability. I'm currently using VS Code and MSYS2 (mingw64) with GCC 8.3.0. I threw together a working example that demonstrates how I attempt to build a simple class. Does my code look reasonable? Am I performing any bad habits (within reason considering that I'm not using a framework)? Does this currently leak memory? Let me know what you think.
#include <objc/objc.h>
#include <objc/runtime.h>
#include <objc/Object.h>
#include <stdio.h>
#include <stdlib.h>
@interface Test : Object
int value;
+(const char *)classStringValue;
-(void)incrementBy: (int)num;
@end
@implementation Test
+(id)alloc
id obj = malloc(class_getInstanceSize(self));
object_setClass(obj, self);
return obj;
-(void)dealloc
free(self);
-(id)init
value = 0;
return self;
+(const char *)classStringValue
return "This is the string value of the Test class";
-(const char *)integerString
if (value >= 5)
return "high";
else
return "low";
-(void)incrementBy: (int)num
value += num;
@end
int main(int argc, char **argv)
printf("%sn", [Test classStringValue]);
Test *testobj = [[Test alloc] init];
printf("%sn", [testobj integerString]);
[testobj incrementBy: 5];
printf("%sn", [testobj integerString]);
printf("%dn", (int)[testobj class]);
printf("%dn", (int)[Object class]);
printf("%dn", [Object isEqual: testobj]);
printf("%dn", [testobj isEqual: testobj]);
[testobj dealloc];
return EXIT_SUCCESS;
objective-c windows
$endgroup$
add a comment |
$begingroup$
I have been developing a cross-platform game based on open C libraries (mainly glfw) with a direct focus on Windows development. The beginning of my programming career taught me familiarity in Objective-C, however I've been using pure C for the past few years in embedded applications.
Now that I'm trying to return to proper desktop program development, I'm wondering if it's a good idea to transfer my Objective-C skills to Windows in order to tidy up my C code. My current way of programming is creating a struct for data that I need and then creating functions around those structs: struct Point int x, int y; and then float Point_calculateDistance(struct Point *obj1, struct Point *obj2). This approach to me seemed very redundant and too object-oriented to write all in C. It would make more sense to me to write an Objective-C class to do this where everything can be more encapsulated.
I prefer not to use any framework for my code to increase the portability. I'm currently using VS Code and MSYS2 (mingw64) with GCC 8.3.0. I threw together a working example that demonstrates how I attempt to build a simple class. Does my code look reasonable? Am I performing any bad habits (within reason considering that I'm not using a framework)? Does this currently leak memory? Let me know what you think.
#include <objc/objc.h>
#include <objc/runtime.h>
#include <objc/Object.h>
#include <stdio.h>
#include <stdlib.h>
@interface Test : Object
int value;
+(const char *)classStringValue;
-(void)incrementBy: (int)num;
@end
@implementation Test
+(id)alloc
id obj = malloc(class_getInstanceSize(self));
object_setClass(obj, self);
return obj;
-(void)dealloc
free(self);
-(id)init
value = 0;
return self;
+(const char *)classStringValue
return "This is the string value of the Test class";
-(const char *)integerString
if (value >= 5)
return "high";
else
return "low";
-(void)incrementBy: (int)num
value += num;
@end
int main(int argc, char **argv)
printf("%sn", [Test classStringValue]);
Test *testobj = [[Test alloc] init];
printf("%sn", [testobj integerString]);
[testobj incrementBy: 5];
printf("%sn", [testobj integerString]);
printf("%dn", (int)[testobj class]);
printf("%dn", (int)[Object class]);
printf("%dn", [Object isEqual: testobj]);
printf("%dn", [testobj isEqual: testobj]);
[testobj dealloc];
return EXIT_SUCCESS;
objective-c windows
$endgroup$
add a comment |
$begingroup$
I have been developing a cross-platform game based on open C libraries (mainly glfw) with a direct focus on Windows development. The beginning of my programming career taught me familiarity in Objective-C, however I've been using pure C for the past few years in embedded applications.
Now that I'm trying to return to proper desktop program development, I'm wondering if it's a good idea to transfer my Objective-C skills to Windows in order to tidy up my C code. My current way of programming is creating a struct for data that I need and then creating functions around those structs: struct Point int x, int y; and then float Point_calculateDistance(struct Point *obj1, struct Point *obj2). This approach to me seemed very redundant and too object-oriented to write all in C. It would make more sense to me to write an Objective-C class to do this where everything can be more encapsulated.
I prefer not to use any framework for my code to increase the portability. I'm currently using VS Code and MSYS2 (mingw64) with GCC 8.3.0. I threw together a working example that demonstrates how I attempt to build a simple class. Does my code look reasonable? Am I performing any bad habits (within reason considering that I'm not using a framework)? Does this currently leak memory? Let me know what you think.
#include <objc/objc.h>
#include <objc/runtime.h>
#include <objc/Object.h>
#include <stdio.h>
#include <stdlib.h>
@interface Test : Object
int value;
+(const char *)classStringValue;
-(void)incrementBy: (int)num;
@end
@implementation Test
+(id)alloc
id obj = malloc(class_getInstanceSize(self));
object_setClass(obj, self);
return obj;
-(void)dealloc
free(self);
-(id)init
value = 0;
return self;
+(const char *)classStringValue
return "This is the string value of the Test class";
-(const char *)integerString
if (value >= 5)
return "high";
else
return "low";
-(void)incrementBy: (int)num
value += num;
@end
int main(int argc, char **argv)
printf("%sn", [Test classStringValue]);
Test *testobj = [[Test alloc] init];
printf("%sn", [testobj integerString]);
[testobj incrementBy: 5];
printf("%sn", [testobj integerString]);
printf("%dn", (int)[testobj class]);
printf("%dn", (int)[Object class]);
printf("%dn", [Object isEqual: testobj]);
printf("%dn", [testobj isEqual: testobj]);
[testobj dealloc];
return EXIT_SUCCESS;
objective-c windows
$endgroup$
I have been developing a cross-platform game based on open C libraries (mainly glfw) with a direct focus on Windows development. The beginning of my programming career taught me familiarity in Objective-C, however I've been using pure C for the past few years in embedded applications.
Now that I'm trying to return to proper desktop program development, I'm wondering if it's a good idea to transfer my Objective-C skills to Windows in order to tidy up my C code. My current way of programming is creating a struct for data that I need and then creating functions around those structs: struct Point int x, int y; and then float Point_calculateDistance(struct Point *obj1, struct Point *obj2). This approach to me seemed very redundant and too object-oriented to write all in C. It would make more sense to me to write an Objective-C class to do this where everything can be more encapsulated.
I prefer not to use any framework for my code to increase the portability. I'm currently using VS Code and MSYS2 (mingw64) with GCC 8.3.0. I threw together a working example that demonstrates how I attempt to build a simple class. Does my code look reasonable? Am I performing any bad habits (within reason considering that I'm not using a framework)? Does this currently leak memory? Let me know what you think.
#include <objc/objc.h>
#include <objc/runtime.h>
#include <objc/Object.h>
#include <stdio.h>
#include <stdlib.h>
@interface Test : Object
int value;
+(const char *)classStringValue;
-(void)incrementBy: (int)num;
@end
@implementation Test
+(id)alloc
id obj = malloc(class_getInstanceSize(self));
object_setClass(obj, self);
return obj;
-(void)dealloc
free(self);
-(id)init
value = 0;
return self;
+(const char *)classStringValue
return "This is the string value of the Test class";
-(const char *)integerString
if (value >= 5)
return "high";
else
return "low";
-(void)incrementBy: (int)num
value += num;
@end
int main(int argc, char **argv)
printf("%sn", [Test classStringValue]);
Test *testobj = [[Test alloc] init];
printf("%sn", [testobj integerString]);
[testobj incrementBy: 5];
printf("%sn", [testobj integerString]);
printf("%dn", (int)[testobj class]);
printf("%dn", (int)[Object class]);
printf("%dn", [Object isEqual: testobj]);
printf("%dn", [testobj isEqual: testobj]);
[testobj dealloc];
return EXIT_SUCCESS;
objective-c windows
objective-c windows
asked 11 mins ago
dylanweberdylanweber
1828
1828
add a comment |
add a comment |
0
active
oldest
votes
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216611%2fis-this-a-good-start-for-an-objective-c-program-written-without-a-framework%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216611%2fis-this-a-good-start-for-an-objective-c-program-written-without-a-framework%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
