我想知道如何在iPhone中的字符串中保存数组(Objective-c).因为我有一个数据数组
数组[0] = 01数组[1] = 02数组[2] = 03数组[3] = 04
现在我想将它保存在这样的字符串中
NSString *string = @"01, 02, 03, 04";
Run Code Online (Sandbox Code Playgroud)
如果你有一些想法,请帮助我,我是这个领域的新手.
提前.
我不理解它后面的循环语句和表达式.请帮我理解.
#include<stdio.h>
int main()
{
int x = 1;
int y = 1;
for( ; y ; printf("%d %d\n",x,y))
y = x++ <= 5;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到的输出
2 1
3 1
4 1
5 1
6 1
7 0
Run Code Online (Sandbox Code Playgroud) 如何加载UIActivityIndicatorView登录页面?就像facebook iPhone App一样.
我有一个名为myString.i的NSString对象需要在我的字符串的每一侧附加一个空格.任何人都可以告诉我这样做的好方法吗?
我是iPhone开发的初学者,我使用.net网络和窗口应用程序,只使用c#语言.
我打算为iPhone制作简单的应用程序.经过长时间的搜索,我开始知道xcode工具包用于开发,而目标c是使用的语言.
我对许多问题感到困惑.请帮助我
从初学者的角度来看,这些是我需要了解的一些基本内容.
请帮助您了解有关学习iPhone开发的所有基础知识的宝贵答案
我有一个应用程序,每次恢复它时都会崩溃.
我希望当用户单击"主页"按钮时,应用程序应该关闭而不是进入后台模式.
那可能吗?如果是,请告诉我.
如果没有,那么解决方法是什么,以便我恢复时我的应用程序不会崩溃?
谢谢!
#include <stdio.h>
#include <stdlib.h>
int main() {
double w, h, b;
printf("Enter your weight in pounds \n");
scanf("%d", &w);
printf("Enter your height in inches \n");
scanf("%d", &h);
h = h/12;
b = w*703 / (h*h);
if (b < 18.5) {
printf("underweight");
} else if (b>=18.5 && b<25) {
printf("normal");
} else {
printf("overweight");
}
system("Pause");
}
Run Code Online (Sandbox Code Playgroud)
好吧所以我的代码打印"体重不足*无论我输入什么数字,我都不知道为什么.如果有人能指出我正确的方向,将非常感谢
我使用一些按钮创建了一个自定义键盘。我使用界面构建器创建了它们,然后创建了一个CustomKeyboardView文件..
所以我有3个文件
我正在将这个视图添加到我的UIViewController喜欢这个
-(void)createCustomKeyboard{
//kbdCustom is an instance of CustomKeyboardView
kbdCustom = [[[NSBundle mainBundle] loadNibNamed:@"CustomKeyBoardView"
owner:self options:nil] objectAtIndex:0];
kbdCustom.delegate = self;
CGRect frame = kbdCustom.frame;
frame.origin.x = 14.0;
frame.origin.y = 300.0;
kbdCustom.frame = frame;
kbdCustom.backgroundColor = [UIColor clearColor];
[self.view addSubview:kbdCustom];
[self.view bringSubviewToFront:kbdCustom];
}
Run Code Online (Sandbox Code Playgroud)
我在屏幕上看到自定义键盘。但我无法触摸任何按钮。
CustomKeyBoardView.m文件中没有什么花哨的 。我有一些按钮处理程序来处理键盘中每种不同类型的按钮。
@implementation CustomKeyBoardView
- (IBAction)numberPressed:(id)sender {
NSLog(@"Number pressed");
}
- (IBAction)specialCharsPressed:(id)sender {
NSLog(@"specialCharsPressed");
}
- (IBAction)clearTextPressed:(id)sender {
NSLog(@"clearTextPressed");
}
- (IBAction)enterButtonPressed:(id)sender {
NSLog(@"enterButtonPressed");
}
@end
Run Code Online (Sandbox Code Playgroud)
其他一些可能对您有帮助的要点(帮助我) …
我知道在c语言中,我需要在分配后释放内存.(我来自java),对此我有几个问题:
当我在做的时候:
int array[30];
Run Code Online (Sandbox Code Playgroud)
(即创建一个大小为30的整数数组)这与做什么一样?
int array[] = malloc(sizeof(int)*30);
Run Code Online (Sandbox Code Playgroud)作为第一个问题的序列,当我在函数内部创建数组(即函数的本地数据而不是整个文件的全局数据)时,我是否需要在创建它的函数内释放此数组的内存?(我没有看到任何其他方法来释放它,因为我无法传递创建回main()函数的所有数组的引用).
所以简而言之,我想知道我何时需要为创建的对象/基元(在函数内部或外部)释放内存.
我有一个从流反序列化的动态char数组.
char *myarray文件内容(使用hexal编辑器):
4F 4B 20 31 32 20 0D 0A 00 00 B4 7F
Run Code Online (Sandbox Code Playgroud)
strlen(myarray) 返回8,(必须是12)
ios ×6
c ×4
cocoa-touch ×4
arrays ×3
iphone ×2
nsstring ×2
objective-c ×2
append ×1
c++ ×1
declaration ×1
ios4 ×1
loading ×1
malloc ×1
strlen ×1
xib ×1