每当我的应用程序启动时,我都会看到黑屏.没有错误消息,我已将主nib文件设置在.plist文件中.这是我的一些代码.
AppDelegate.h
#import <UIKit/UIKit.h>
@class LoginController;
@interface ViiadAppDelegate : NSObject <UIApplicationDelegate> {
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet LoginController *viewController;
@end
Run Code Online (Sandbox Code Playgroud)
AppDelegate.m
#import "AppDelegate.h"
#import "LoginController.h"
@implementation AppDelegate
@synthesize window=_window;
@synthesize viewController=_viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.我是iPhone开发的新手.
每当我使用该SHA256.Create()方法时,它总是返回一个空值.这是我加密密码的方法......
private string EncryptPassword(string password)
{
SHA256 sha = SHA256.Create(password);
return BitConverter.ToString(sha.Hash);
}
Run Code Online (Sandbox Code Playgroud)
调试器显示该变量sha为null.我甚至尝试将它放在一个控制器中的自己的方法,但我仍然得到一个System.NullReferenceException
public String Index()
{
return BitConverter.ToString(SHA256.Create("Hello World").Hash);
}
Run Code Online (Sandbox Code Playgroud)
我完全迷失了.有什么东西我显然做错了吗?
@using (Html.BeginForm("Create", "Posts", FormMethod.Post, new { id = "publish" }))
{
@Html.AntiForgeryToken("Posts/Create")
<input type="text" id="url" name="url" />
<input type="submit" value="@Html.Resource("Publish")" />
}
[HttpPost]
[ValidateAntiForgeryToken]
public JsonResult Create(string url)
{
// stuff that's never reached
}
Run Code Online (Sandbox Code Playgroud)
在验证CSRF令牌时,我无法意识到这个简单形式的失败.我该怎么调试呢?
更新
如果我取出盐,它的作用; 奇怪的是它曾经与盐一起使用,我无法弄清楚为什么它不再存在.
我正在尝试编写一个函数,它将切断字段中的前4个字符.例如,如果字段的值是ABC_123_EFG它将返回123_EFG.我试图使用LEFT和LEN功能的组合,但没有取得任何成功.
这是我认为它应该是......
RIGHT(code, LEN(code) - 4) AS code_concat
Run Code Online (Sandbox Code Playgroud)
但它失败了这个错误
Msg 536, Level 16, State 2, Line 2
Invalid length parameter passed to the RIGHT function.
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?这是实现这一目标的最佳方式吗?
我有一个ArrayAdapter,我需要获得应用程序的共享首选项,以便用它做一些事情.我的问题我不能得到共享的偏好.那就是我的代码:
public class MobileArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[] values;
private static SharedPreferences prefs;
private String firstBtName = "";
private String secondBtName = "";
private String thirdBtName = "";
public MobileArrayAdapter(Context context, String[] values) {
super(context, R.layout.list, values);
this.context = context;
this.values = values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
prefs = getSharedPreferences("MYPREFS", 0); // ERROR **************
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.list, parent, false);
TextView …Run Code Online (Sandbox Code Playgroud) 问题
我目前正在为我的MVC项目添加自动化,而且我被卡住了.现在我有一个User模型用于表示数据库中的数据.我必须将该模型映射到EditUserModel,这将在调用Edit方法时使用.EditUserModel IEnumerable<SelectListItem>(对于下拉菜单)我似乎无法弄清楚如何映射.
试图解决方案
截至目前,我还没有尝试过任何事情.我不确定在哪里IEnumerable<SelectListItem>或哪里填充它的最佳位置.现在它正在控制器中填充.
User.cs
public class User
{
[Key]
public int UserID { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public int RoleID { get; set; }
[ForeignKey("RoleID")]
public virtual Role Role { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
EditUserModel.cs
public class EditUserViewModel
{
[HiddenInput(DisplayValue = false)]
public int UserID { get; set; }
[Required]
public String Username { get; set; }
[Required]
[DataType(DataType.Password)]
public string Password …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Python的sorted函数对列表进行排序.在Python 3中,cmp删除了关键字参数.不幸的是,我似乎无法使用key关键字参数实现我的算法,因为我需要两个对象来比较数据.
示例排序数据
59 59
59 3 1 1
59 4 3 3
61 1
61 10
61 237
61 1 1 1
Run Code Online (Sandbox Code Playgroud)
比较功能
NUM_RE = re.compile("[\d]+")
def compare(x, y):
# Aggregate our data into integer arrays
x_result = [int(x) for x in NUM_RE.findall(x)]
y_result = [int(y) for y in NUM_RE.findall(y)]
# Return if there is a non-zero difference in the first element
statement_diff = x_result[0] - y_result[0]
if statement_diff != 0:
return statement_diff …Run Code Online (Sandbox Code Playgroud) 我想创建一个表单,在查看时,从数据库中查询用户最喜欢的水果并显示如下:
<select size="4">
<option selected>Apples</option>
<option>Bananas</option>
<option>Oranges</option>
<option>Watermelon</option>
</select>
Run Code Online (Sandbox Code Playgroud)
使用该表单的视图将:
我正在考虑使用 ChoiceField,但看起来您无法将选项列表动态加载到表单中,至少以一种直接的方式。我最好跳过表单并直接在模板中生成代码吗?或者有没有办法在视图中加载带有用户项的表单的 ChoiceField ?
另外,是否有任何一般的经验法则表明使用 django 表单字段构建表单与在模板中生成表单代码相比更容易?
好的,所以我知道在这个问题上有一堆问题,但在阅读它们并尝试使用这些方法之后,我的应用程序似乎仍然会泄漏内存.我研究上的内存Manegment苹果直营店和读取显着的问题在这里,这里和这里.我有一个方法解析一个JSON字符串,然后将它们返回到一个NSMutableDictionary.我autorelease从返回方法调用该对象,然后调用retain接收方法(确保该对象在池的下一个排水管上不是dealloc).然后,当我完成它时,我释放对象.但它仍然泄漏.谁能看到我做错了什么?
退货方法
+ (NSMutableArray *)parseSpecialtyResult:(NSString *)json
{
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSDictionary *dictionary = [parser objectWithString:json];
NSArray *jsonObjects = [dictionary valueForKey:@"Rows"];
NSMutableArray *jsonArray = [[NSMutableArray alloc] initWithCapacity:[jsonObjects count]];
//Storing objects
for (NSDictionary *dict in jsonObjects)
{
Specialty *specialty = [[Specialty alloc] init];
[specialty setName:[dict objectForKey:@"name"]];
[specialty setIdenity:[dict objectForKey:@"id"]];
[jsonArray addObject:specialty];
}
[parser release];
//Relinquish ownership of this object
return [jsonArray autorelease];
}
Run Code Online (Sandbox Code Playgroud)
打电话给班级
- …Run Code Online (Sandbox Code Playgroud) 您好我正在寻找一个类似于CONTAINS函数的函数,但是,它不需要对该字段进行全文索引.基本上我有一个字段,其中包含一些由空格分隔的代码ABC DEF GHI.我想运行一个查询,看看是否DEF在该字段中.我该怎么做呢?
它返回NullPointerException时,我点击播放按钮,我想停止按钮,它应该会返回1,它崩溃时,我点击播放按钮getCount将()方法,这是在服务类的值绑定.这是活动类:
public class MainMP3 extends Activity{
Button stop;
static final String MEDIA_PATH = new String("/sdcard/");
Button data_display;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mp3interface);
startService(new Intent(MainMP3.this, ServiceMP3.class));
stop= (Button) findViewById(R.id.stop);
// to stop service
//stopService(new Intent(MainMP3.this, ServiceMP3.class));
Button button = (Button)findViewById(R.id.play);
button.setOnClickListener(new StartClick());
}
private ServiceMP3 service = null;
private ServiceConnection connection = new ServiceConnection() {
@Override // Called when connection is made
public void onServiceConnected(ComponentName cName, IBinder binder) {
service = ((ServiceMP3.SlowBinder)binder).getService();
}
@Override //
public …Run Code Online (Sandbox Code Playgroud) android ×2
c# ×2
ios ×2
iphone ×2
objective-c ×2
sql ×2
sql-server ×2
.net ×1
asp.net ×1
asp.net-mvc ×1
automapper ×1
autorelease ×1
csrf ×1
django ×1
forms ×1
python ×1
python-3.x ×1
salt ×1
service ×1
sha ×1
sorting ×1
viewmodel ×1